-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
undecided: | ||
- root-workspace-0b6124 | ||
- "@tonic-foundation/config" | ||
- "@tonic-foundation/storage" | ||
- "@tonic-foundation/token" | ||
- "@tonic-foundation/transaction" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
"trailingComma": "es5", | ||
"singleQuote": true | ||
}, | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Functions for checking status of a transaction, including | ||
* checking for errors in a promise chain. | ||
*/ | ||
import { Near } from 'near-api-js'; | ||
import { | ||
FinalExecutionOutcome, | ||
JsonRpcProvider, | ||
} from 'near-api-js/lib/providers'; | ||
import { ExecutionOutcome } from 'near-api-js/lib/providers/provider'; | ||
|
||
export function isErrorStatus( | ||
s: ExecutionOutcome['status'] | FinalExecutionOutcome['status'] | ||
): boolean { | ||
if (typeof s === 'string') { | ||
return s === 'Failure'; | ||
} | ||
return 'Failure' in s; | ||
} | ||
|
||
/** | ||
* | ||
* @param txId | ||
* @returns true if success, false otherwise | ||
*/ | ||
export async function didTxSucceed( | ||
near: Near, | ||
accountId: string, | ||
txId: string | ||
): Promise<boolean> { | ||
// It's not exactly this. Actual rpc response has more fields, but we only | ||
// need these fields for what we're doing. RPC will throw its own errors, | ||
// so it's fine to use the type as is. | ||
const ret: FinalExecutionOutcome = await ( | ||
near.connection.provider as JsonRpcProvider | ||
).sendJsonRpc('EXPERIMENTAL_tx_status', [txId, accountId]); | ||
|
||
const hasError = ret.receipts_outcome.some((o) => { | ||
return isErrorStatus(o.outcome.status); | ||
}); | ||
|
||
return !isErrorStatus(ret.status) && !hasError; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,8 @@ __metadata: | |
version: 0.0.0-use.local | ||
resolution: "@tonic-foundation/storage@workspace:packages/storage" | ||
dependencies: | ||
"@tonic-foundation/transaction": 1.0.1 | ||
"@tonic-foundation/utils": 1.0.1 | ||
"@tonic-foundation/transaction": 1.0.2 | ||
"@tonic-foundation/utils": 1.0.2 | ||
"@tsconfig/recommended": ^1.0.1 | ||
"@types/bn.js": ^5.1.0 | ||
bn.js: ^5.2.0 | ||
|
@@ -44,8 +44,8 @@ __metadata: | |
version: 0.0.0-use.local | ||
resolution: "@tonic-foundation/token@workspace:packages/token" | ||
dependencies: | ||
"@tonic-foundation/transaction": 1.0.1 | ||
"@tonic-foundation/utils": 1.0.1 | ||
"@tonic-foundation/transaction": 1.0.2 | ||
"@tonic-foundation/utils": 1.0.2 | ||
"@tsconfig/recommended": ^1.0.1 | ||
"@types/bn.js": ^5.1.0 | ||
bn.js: ^5.2.1 | ||
|
@@ -54,12 +54,12 @@ __metadata: | |
languageName: unknown | ||
linkType: soft | ||
|
||
"@tonic-foundation/[email protected].1, @tonic-foundation/transaction@workspace:packages/transaction": | ||
"@tonic-foundation/[email protected].2, @tonic-foundation/transaction@workspace:packages/transaction": | ||
version: 0.0.0-use.local | ||
resolution: "@tonic-foundation/transaction@workspace:packages/transaction" | ||
dependencies: | ||
"@near-wallet-selector/core": ^7.0.0 | ||
"@tonic-foundation/utils": 1.0.1 | ||
"@tonic-foundation/utils": 1.0.2 | ||
"@tsconfig/recommended": ^1.0.1 | ||
"@types/bn.js": ^5.1.0 | ||
bn.js: ^5.2.0 | ||
|
@@ -68,7 +68,7 @@ __metadata: | |
languageName: unknown | ||
linkType: soft | ||
|
||
"@tonic-foundation/[email protected].1, @tonic-foundation/utils@workspace:packages/utils": | ||
"@tonic-foundation/[email protected].2, @tonic-foundation/utils@workspace:packages/utils": | ||
version: 0.0.0-use.local | ||
resolution: "@tonic-foundation/utils@workspace:packages/utils" | ||
dependencies: | ||
|