@polymeshassociation/polymesh-sdk 31.0.0 → 31.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +2 -136
  3. package/api/client/AccountManagement.d.ts +48 -0
  4. package/api/client/AccountManagement.d.ts.map +1 -1
  5. package/api/client/AccountManagement.js +38 -0
  6. package/api/client/AccountManagement.js.map +1 -1
  7. package/api/client/Network.d.ts +79 -2
  8. package/api/client/Network.d.ts.map +1 -1
  9. package/api/client/Network.js +143 -12
  10. package/api/client/Network.js.map +1 -1
  11. package/api/client/types.d.ts +6 -0
  12. package/api/client/types.d.ts.map +1 -1
  13. package/api/client/types.js +6 -0
  14. package/api/client/types.js.map +1 -1
  15. package/api/entities/Account/index.d.ts +35 -1
  16. package/api/entities/Account/index.d.ts.map +1 -1
  17. package/api/entities/Account/index.js +89 -0
  18. package/api/entities/Account/index.js.map +1 -1
  19. package/api/entities/Account/types.d.ts +60 -1
  20. package/api/entities/Account/types.d.ts.map +1 -1
  21. package/api/entities/Account/types.js +25 -1
  22. package/api/entities/Account/types.js.map +1 -1
  23. package/api/entities/Asset/NonFungible/NftCollection.js +2 -2
  24. package/api/entities/Asset/NonFungible/NftCollection.js.map +1 -1
  25. package/api/procedures/issueNft.d.ts +1 -0
  26. package/api/procedures/issueNft.d.ts.map +1 -1
  27. package/api/procedures/issueNft.js +24 -6
  28. package/api/procedures/issueNft.js.map +1 -1
  29. package/api/procedures/toggleEvmAccountMapping.d.ts +18 -0
  30. package/api/procedures/toggleEvmAccountMapping.d.ts.map +1 -0
  31. package/api/procedures/toggleEvmAccountMapping.js +80 -0
  32. package/api/procedures/toggleEvmAccountMapping.js.map +1 -0
  33. package/api/procedures/types.d.ts +44 -0
  34. package/api/procedures/types.d.ts.map +1 -1
  35. package/api/procedures/types.js.map +1 -1
  36. package/base/Context.d.ts +33 -0
  37. package/base/Context.d.ts.map +1 -1
  38. package/base/Context.js +59 -1
  39. package/base/Context.js.map +1 -1
  40. package/base/PolymeshTransactionBase.d.ts +199 -3
  41. package/base/PolymeshTransactionBase.d.ts.map +1 -1
  42. package/base/PolymeshTransactionBase.js +595 -137
  43. package/base/PolymeshTransactionBase.js.map +1 -1
  44. package/base/Procedure.d.ts.map +1 -1
  45. package/base/Procedure.js +2 -0
  46. package/base/Procedure.js.map +1 -1
  47. package/base/ethTransaction.d.ts +222 -0
  48. package/base/ethTransaction.d.ts.map +1 -0
  49. package/base/ethTransaction.js +317 -0
  50. package/base/ethTransaction.js.map +1 -0
  51. package/base/types.d.ts +66 -1
  52. package/base/types.d.ts.map +1 -1
  53. package/base/types.js.map +1 -1
  54. package/base/utils.d.ts +60 -11
  55. package/base/utils.d.ts.map +1 -1
  56. package/base/utils.js +328 -45
  57. package/base/utils.js.map +1 -1
  58. package/internal.d.ts +1 -0
  59. package/internal.d.ts.map +1 -1
  60. package/internal.js +4 -2
  61. package/internal.js.map +1 -1
  62. package/npm-package/polymeshassociation-polymesh-sdk-31.1.0-beta.2.tgz +0 -0
  63. package/package.json +2 -2
  64. package/types/internal.d.ts +38 -1
  65. package/types/internal.d.ts.map +1 -1
  66. package/types/internal.js.map +1 -1
  67. package/utils/eth.d.ts +63 -0
  68. package/utils/eth.d.ts.map +1 -0
  69. package/utils/eth.js +209 -0
  70. package/utils/eth.js.map +1 -0
  71. package/utils/internal.d.ts +19 -1
  72. package/utils/internal.d.ts.map +1 -1
  73. package/utils/internal.js +34 -0
  74. package/utils/internal.js.map +1 -1
  75. package/utils/typeguards.d.ts +10 -0
  76. package/utils/typeguards.d.ts.map +1 -1
  77. package/utils/typeguards.js +11 -0
  78. package/utils/typeguards.js.map +1 -1
  79. package/npm-package/polymeshassociation-polymesh-sdk-31.0.0.tgz +0 -0
Binary file
package/CHANGELOG.md CHANGED
@@ -1,140 +1,6 @@
1
- # [31.0.0](https://github.com/PolymeshAssociation/polymesh-sdk/compare/v30.2.0...v31.0.0) (2026-08-14)
2
-
3
-
4
- * fix!: 🐛 require expiresAt on off-chain settlement and STO receipts ([1473bc3](https://github.com/PolymeshAssociation/polymesh-sdk/commit/1473bc3749248826a69330d9fc1dbaf67202c736))
5
-
6
-
7
- ### Bug Fixes
8
-
9
- * 🐛 authorise ballot voting as a holder action ([aa36fc0](https://github.com/PolymeshAssociation/polymesh-sdk/commit/aa36fc0a3177e2926397a01d2cc601b283a83518)), closes [#1643](https://github.com/PolymeshAssociation/polymesh-sdk/issues/1643)
10
- * 🐛 base transferFunds authorization on signing key, add NFT checks ([64adfd9](https://github.com/PolymeshAssociation/polymesh-sdk/commit/64adfd91710c0843e87bf902c3c73bdcda68d5d1))
11
- * 🐛 check agent permissions for the accept-side transaction ([394fb58](https://github.com/PolymeshAssociation/polymesh-sdk/commit/394fb588fb1d71ff1c4f5290572d470361ae9e08))
12
- * 🐛 compare NFT ownership by address for MultiSig Account holders in transferFunds ([816a5f7](https://github.com/PolymeshAssociation/polymesh-sdk/commit/816a5f799d9e6fb15e4e62b84410a5dfad019a9d))
13
- * 🐛 correct protocol fee mapping against v8 runtime ([69ec025](https://github.com/PolymeshAssociation/polymesh-sdk/commit/69ec025da27bc62d5ffb7476487b26296390ff49))
14
- * 🐛 correct transaction tags against chain v8 metadata ([e77224d](https://github.com/PolymeshAssociation/polymesh-sdk/commit/e77224dce8ab3bb3a4c2edd19d8ac2a43b10d204))
15
- * 🐛 declare the transaction revokeIdentityToCreatePortfolios submits ([debc1d0](https://github.com/PolymeshAssociation/polymesh-sdk/commit/debc1d065da6a8e6a36f102e0ac5b26c020ab9ed))
16
- * 🐛 declare the transactions procedures actually submit ([672fcfd](https://github.com/PolymeshAssociation/polymesh-sdk/commit/672fcfd3d1a7c3f4b4fb8756d65c789f6ad3a2f3))
17
- * 🐛 distinguish immediate execution from a pending instruction ([9c40cf9](https://github.com/PolymeshAssociation/polymesh-sdk/commit/9c40cf91ca1772812a03a0aa3fb530294b82298d))
18
- * 🐛 drop permission declarations the chain never checks ([ec0ddbb](https://github.com/PolymeshAssociation/polymesh-sdk/commit/ec0ddbbb395d0393119bf99b29079cafa8650fe2))
19
- * 🐛 drop remaining permission declarations the chain never checks ([fdb8f75](https://github.com/PolymeshAssociation/polymesh-sdk/commit/fdb8f75f968f607fd8c9b9654bd59c75564ada65))
20
- * 🐛 make generate:consts idempotent ([1c9b080](https://github.com/PolymeshAssociation/polymesh-sdk/commit/1c9b08096a2aba5c8ea98cbc561c4230245c7058))
21
- * 🐛 only require the DID Registrar role to issue a CDD claim ([78abd14](https://github.com/PolymeshAssociation/polymesh-sdk/commit/78abd14d912d85e61bdcaeda6fe5a0ed668d5f0c))
22
- * 🐛 protocol fees no longer silently reported as zero ([e30e51d](https://github.com/PolymeshAssociation/polymesh-sdk/commit/e30e51dcd3703258060ad2a22f4bd34ad13b397f))
23
- * 🐛 report transfer failures instead of throwing ([50fb337](https://github.com/PolymeshAssociation/polymesh-sdk/commit/50fb337d25beee873d779484b6fb25ec67aa37c4))
24
- * 🐛 return null from getNextCheckpoint after every Schedule is removed ([75d0b0e](https://github.com/PolymeshAssociation/polymesh-sdk/commit/75d0b0ed22f7819905b0804d25b65357d7d9488e))
25
- * 🐛 staking.getPayee returns null for an Account with no payee ([4a8effc](https://github.com/PolymeshAssociation/polymesh-sdk/commit/4a8effcabb8140fa01d812c11c5ab693778735be))
1
+ # [31.1.0-beta.2](https://github.com/PolymeshAssociation/polymesh-sdk/compare/v31.1.0-beta.1...v31.1.0-beta.2) (2026-08-21)
26
2
 
27
3
 
28
4
  ### Features
29
5
 
30
- * 🎸 add Checkpoint.Schedules.getNextCheckpoint getter ([31db08c](https://github.com/PolymeshAssociation/polymesh-sdk/commit/31db08ccc433dde93355f5f90f0d2c7e36766259))
31
- * 🎸 add CorporateActionBase.getDocuments getter ([edef2cb](https://github.com/PolymeshAssociation/polymesh-sdk/commit/edef2cb4567aa85f0b100d80cf38b6464e8e07e8))
32
- * 🎸 align TransferError with the chain's transfer errors ([52f1364](https://github.com/PolymeshAssociation/polymesh-sdk/commit/52f13642eeec5397818afe09e1734be70ba2075a))
33
- * 🎸 allow transferFunds between asset holders on different DIDs ([458bfd5](https://github.com/PolymeshAssociation/polymesh-sdk/commit/458bfd5d28d156e1633ffd5970df41afd1d9374e))
34
- * 🎸 Drop v7 support ([4292be3](https://github.com/PolymeshAssociation/polymesh-sdk/commit/4292be303bb5bd161b83ce92ed9ea7b1993e82e7))
35
- * 🎸 make nft.createNftCollection grantable to External Agents ([32753ef](https://github.com/PolymeshAssociation/polymesh-sdk/commit/32753ef90ff9e1bc010e344e66155fd89a44ffe7))
36
- * 🎸 rebuild transaction groups from the chain's permission model ([b6cb8e5](https://github.com/PolymeshAssociation/polymesh-sdk/commit/b6cb8e5ee0b13903cf8f0e92050272800a260372))
37
- * 🎸 remove CDD transfer errors that cannot occur on v8 ([10114e3](https://github.com/PolymeshAssociation/polymesh-sdk/commit/10114e300392e9bb9f05406ce0f85bdcdda7774d))
38
- * 🎸 remove types and a procedure for extrinsics that no longer exist ([2fb7fec](https://github.com/PolymeshAssociation/polymesh-sdk/commit/2fb7fecbcc64eff17682a8e9c0c15732d433255c))
39
-
40
-
41
- ### BREAKING CHANGES
42
-
43
- * `expiresAt` is now required on
44
- `Instruction.generateOffChainAffirmationReceipt` and
45
- `Offering.generateOffChainFundingReceipt`, and on
46
- `OffChainAffirmationReceipt` and `OffChainFundingReceipt`.
47
- * 🧨 `Assets.transferFunds` return type changed from
48
- `void` to `Instruction | undefined`. It resolves to the pending
49
- `Instruction` when a cross-DID transfer is left awaiting the
50
- receiver's affirmation, and `undefined` when the transfer settles
51
- immediately (same-DID, or the receiver auto-affirmed).
52
- * 🧨 The following exported types are removed, along with the
53
- `modifyCorporateActionsAgent` procedure:
54
-
55
- - `ScopeClaimProof` and `AddInvestorUniquenessClaimParams` — described
56
- `identity.add_investor_uniqueness_claim`, which does not exist on chain v8
57
- - `ModifyPrimaryIssuanceAgentParams` — the Primary Issuance Agent concept was
58
- superseded by External Agents
59
- - `ModifyCorporateActionsAgentParams` — its procedure's only caller,
60
- `CorporateActions.setAgent`, was removed in v22.0.0 in favour of
61
- `Permissions.inviteAgent`, but the procedure was left behind
62
-
63
- None had any reference in the SDK and no procedure accepted or returned them.
64
- There is no replacement because there is no longer an operation to describe.
65
-
66
- `testUtils` Asset entity mocks no longer default a `primaryIssuanceAgents`
67
- field, which `AssetDetails` has not had since v22.0.0.
68
- * 🧨 - Removed the `TransferStatus` enum and its sole
69
- producer `u8ToTransferStatus`. `TransferError` — the enum actually
70
- populated, by `Settlements.canTransfer` — keeps its role, and its members'
71
- doc comments no longer refer to `TransferStatus` equivalents.
72
- - Removed `TransferError.InvalidReceiverPortfolio`. Its sole producer was
73
- the `granularCanTransferResultToTransferBreakdown` cascade deleted with v7
74
- support, and it cannot be re-mapped: the `portfolio` pallet has a single
75
- `PortfolioDoesNotExist` variant, already mapped to `InvalidSenderPortfolio`.
76
- - Added `TransferError.InvalidReceiverIdentity` for a receiving Identity
77
- that is not active. Both transfer-validation paths report this condition
78
- (`nft.InvalidNFTTransferInvalidReceiverDID` and
79
- `asset.InvalidTransferInvalidReceiverDID`) and neither was mapped, so it
80
- previously surfaced as a raw chain error name.
81
- - Removed the `transfersCanTransfer` mock option in `testUtils`, typed
82
- against a return type `canTransfer` no longer has.
83
- - See [`changelogs/v30.2.0-next.md`](changelogs/v30.2.0-next.md) for full
84
- migration guidance.
85
- * 🧨 - Removed `TransferError.InvalidReceiverCdd`,
86
- `TransferError.InvalidSenderCdd` and `TransferError.ScopeClaimMissing`.
87
- The first two cannot be produced because transfers are no longer CDD
88
- gated; `ScopeClaimMissing` relates to Investor Uniqueness, removed from
89
- the chain some time ago.
90
- - See [`changelogs/v30.2.0-next.md`](changelogs/v30.2.0-next.md) for full
91
- migration guidance.
92
- * 🧨 - Removed `TxGroup.RelayerManagement` and
93
- `RELAYER_MANAGEMENT_TX_TAGS`. Every call in the `relayer` pallet is
94
- `ensure_signed` only, so the group never gated anything and no replacement
95
- grant is needed.
96
- - `TxGroup.MultiSigManagement` / `MULTISIG_MANAGEMENT_TX_TAGS` reduced to
97
- `multiSig.CreateMultisig`, the only permission-checked call in the pallet.
98
- The rest are executed under the MultiSig's own origin via a proposal, are
99
- `ensure_signed` only, or are primary-key only. What a MultiSig may do via
100
- proposal is constrained by the permissions held by the **MultiSig Account
101
- itself**, not by its signers'.
102
- - Added `TxGroup.InstructionMediation` / `INSTRUCTION_MEDIATION_TX_TAGS`
103
- (`AffirmInstructionAsMediator`, `RejectInstructionAsMediator`,
104
- `LockInstruction`, `UnlockInstruction`). These are **newly grantable, not
105
- relocated** — no group previously covered them, so existing
106
- `SettlementManagement` grantees do not already have them.
107
- - Added `TxGroup.DidRegistration` / `DID_REGISTRATION_TX_TAGS`
108
- (`identity.RegisterDid`); `TxGroup.CddRegistration` is deprecated but
109
- retained.
110
- - Removed tags for extrinsics no longer on chain:
111
- `settlement.AddInstructionWithMemo`, `settlement.AddAndAffirmInstructionWithMemo`,
112
- `portfolio.MovePortfolioFundsV2`.
113
- - Added tags for permission-checked v8 extrinsics no group previously
114
- covered, across `SettlementManagement`, `PortfolioManagement`,
115
- `StoManagement` and `CorporateActionsManagement`.
116
- - Consumers building permission UIs from `TX_GROUP_TO_TAGS_MAP`,
117
- `AGENT_TX_GROUP_VALUES` or the individual `*_TX_TAGS` constants should
118
- re-check their output.
119
- - See [`changelogs/v30.2.0-next.md`](changelogs/v30.2.0-next.md) for full
120
- migration guidance.
121
- * 🧨 - SDK now only supports **chain v8** — connecting to a v7 chain throws on
122
- initialization (`SUPPORTED_SPEC_VERSION_RANGE` narrowed to `'8.0'`).
123
- - Removed: `ChildIdentity` entity and all child-identity APIs (`Identities.createChild`/
124
- `createChildren`/`getChildIdentity`, `Identity.*` equivalents), `Claims.getCddClaims`,
125
- `Identity.hasValidCdd`, `RoleType.CddProvider`/`isCddProviderRole`/`CddProviderRole`,
126
- `AccountManagement.subsidizeAccount`, `consumeAddRelayerPayingKeyAuthorization`/
127
- `AuthorizationType.AddRelayerPayingKey`, `Instruction.withdraw`/`withdrawAsMediator`/
128
- `InstructionAffirmationOperation.Withdraw`/`WithdrawAsMediator`, `Nft.controllerTransfer`'s
129
- `destinationPortfolio` param, `AcceptPrimaryKeyRotationParams.cddAuth`,
130
- `SetStakingControllerParams`/`BondPolyxParams.controller`.
131
- - Renamed: `Identity.isCddProvider()` → `Identity.isDidRegistrar()`.
132
- - Deprecated: `Identities.registerIdentity` (`createCdd`/`expiry` are now no-ops) —
133
- use `registerDid`/`selfRegisterDid`.
134
- - Error message changes (update any string-matching code):
135
- `'Beneficiary/Subsidizer Account does not have a valid CDD Claim'` →
136
- `'...does not have an associated Identity'`;
137
- `'Issuing Identity does not have a valid CDD claim'` → `'Issuing Identity does not exist'`;
138
- `'Issuer must be a CDD provider'` → `'Issuer must be a DID Registrar'`;
139
- `'MultiSig signers must be accounts as of v7'` → `'MultiSig signers must be accounts'`.
140
- - See [`changelogs/v30.2.0-next.md`](changelogs/v30.2.0-next.md) for full migration guidance.
6
+ * 🎸 support issuing NFTs to the signing Account, not just portfolios ([68a9ab4](https://github.com/PolymeshAssociation/polymesh-sdk/commit/68a9ab4471516623d2dc60f29ef5b7857f49a12a))
@@ -54,6 +54,35 @@ export declare class AccountManagement {
54
54
  * Unfreeze all of the secondary Accounts in the signing Identity. This will restore their permissions as they were before being frozen
55
55
  */
56
56
  unfreezeSecondaryAccounts: NoArgsProcedureMethod<void>;
57
+ /**
58
+ * Register the signing Account against its derived Ethereum address, so that the chain can
59
+ * resolve that address back to the Account
60
+ *
61
+ * The derived address (see {@link api/entities/Account!Account.evmAddress | Account.evmAddress})
62
+ * is `keccak256` of the Account, which the chain cannot invert on its own. Until it is mapped,
63
+ * anything sent to the address is credited to the fallback Account reported by
64
+ * {@link api/entities/Account!Account.getEvmAddressDetails | Account.getEvmAddressDetails}
65
+ * instead, and recovering it needs the chain's `revive.dispatchAsFallbackAccount`. Map the
66
+ * Account *before* advertising the address or receiving funds at it
67
+ *
68
+ * @note this takes a deposit from the signing Account, released by {@link unmapEvmAccount}
69
+ *
70
+ * @throws if the signing Account is Ethereum-derived — the chain resolves its address by
71
+ * stripping the padding, so there is nothing to map
72
+ * @throws if the signing Account is already mapped
73
+ */
74
+ mapEvmAccount: NoArgsProcedureMethod<void>;
75
+ /**
76
+ * Unregister the signing Account from its derived Ethereum address, releasing the deposit taken
77
+ * by {@link mapEvmAccount}
78
+ *
79
+ * @note after this, the chain can no longer resolve the derived address back to the Account, so
80
+ * anything sent to it is credited to the fallback Account instead. Only do this for an Account
81
+ * that will no longer be used
82
+ *
83
+ * @throws if the signing Account is not mapped
84
+ */
85
+ unmapEvmAccount: NoArgsProcedureMethod<void>;
57
86
  /**
58
87
  * Approves a subsidy request
59
88
  *
@@ -119,6 +148,25 @@ export declare class AccountManagement {
119
148
  getAccount(args: {
120
149
  address: string;
121
150
  }): Promise<Account | MultiSig>;
151
+ /**
152
+ * Return the Account the chain credits for an Ethereum (H160) address, mirroring the `revive`
153
+ * pallet's address mapper
154
+ *
155
+ * - if the address has been mapped via {@link mapEvmAccount}, this is the Account that mapped it
156
+ * - otherwise it is the fallback Account `ss58(<address> ++ [0xEE; 12])`, which is also the
157
+ * Account controlled by the Ethereum key itself when `address` is a native Ethereum address
158
+ *
159
+ * @param args.evmAddress - 20 byte hex encoded Ethereum address. Checksummed or not
160
+ *
161
+ * @note this always resolves to an Account, so the result alone does not say whether a mapping
162
+ * exists. Use {@link api/entities/Account!Account.getEvmAddressDetails |
163
+ * Account.getEvmAddressDetails} on the Account you expect for that
164
+ *
165
+ * @throws if `evmAddress` is not a 20 byte hex encoded address
166
+ */
167
+ getAccountByEvmAddress(args: {
168
+ evmAddress: string;
169
+ }): Promise<Account | MultiSig>;
122
170
  /**
123
171
  * Return the signing Account, or null if no signing Account has been set
124
172
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AccountManagement.d.ts","sourceRoot":"","sources":["../../../src/api/client/AccountManagement.ts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GAAG,QAAQ,CAAC;IAIzE;;;;;;;;;;;;;;;OAeG;IACU,sBAAsB,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;IAgB9F;;OAEG;IACI,iBAAiB,IAAI,OAAO,GAAG,IAAI;IAQ1C;;;;OAIG;IACI,kBAAkB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAI/C;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE;QACtB,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9B,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;KAC9B,GAAG,OAAO;IAWX;;OAEG;IACI,cAAc,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAUzD;;;;;;;OAOG;IACI,gBAAgB,EAAE,eAAe,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;IAE/E;;;;;;OAMG;IACU,6BAA6B,CAAC,IAAI,EAAE;QAC/C,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QACzB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;QAC1B,MAAM,EAAE,IAAI,CAAC;KACd,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;CAyB3B"}
@@ -14,6 +14,7 @@ const util_1 = require("@polkadot/util");
14
14
  const internal_1 = require("../../internal");
15
15
  const types_1 = require("../../types");
16
16
  const conversion_1 = require("../../utils/conversion");
17
+ const eth_1 = require("../../utils/eth");
17
18
  const internal_2 = require("../../utils/internal");
18
19
  /**
19
20
  * Handles functionality related to Account Management
@@ -57,6 +58,14 @@ class AccountManagement {
57
58
  getProcedureAndArgs: () => [internal_1.toggleFreezeSecondaryAccounts, { freeze: false }],
58
59
  voidArgs: true,
59
60
  }, context);
61
+ this.mapEvmAccount = (0, internal_2.createProcedureMethod)({
62
+ getProcedureAndArgs: () => [internal_1.toggleEvmAccountMapping, { map: true }],
63
+ voidArgs: true,
64
+ }, context);
65
+ this.unmapEvmAccount = (0, internal_2.createProcedureMethod)({
66
+ getProcedureAndArgs: () => [internal_1.toggleEvmAccountMapping, { map: false }],
67
+ voidArgs: true,
68
+ }, context);
60
69
  this.acceptSubsidy = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.acceptSubsidy, args] }, context);
61
70
  this.revokeSubsidy = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.revokeSubsidy, args] }, context);
62
71
  this.approveSubsidy = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.subsidizeAccount, Object.assign({}, args)] }, context);
@@ -99,6 +108,35 @@ class AccountManagement {
99
108
  getAccount(args) {
100
109
  return (0, internal_2.getAccount)(args, this.context);
101
110
  }
111
+ /**
112
+ * Return the Account the chain credits for an Ethereum (H160) address, mirroring the `revive`
113
+ * pallet's address mapper
114
+ *
115
+ * - if the address has been mapped via {@link mapEvmAccount}, this is the Account that mapped it
116
+ * - otherwise it is the fallback Account `ss58(<address> ++ [0xEE; 12])`, which is also the
117
+ * Account controlled by the Ethereum key itself when `address` is a native Ethereum address
118
+ *
119
+ * @param args.evmAddress - 20 byte hex encoded Ethereum address. Checksummed or not
120
+ *
121
+ * @note this always resolves to an Account, so the result alone does not say whether a mapping
122
+ * exists. Use {@link api/entities/Account!Account.getEvmAddressDetails |
123
+ * Account.getEvmAddressDetails} on the Account you expect for that
124
+ *
125
+ * @throws if `evmAddress` is not a 20 byte hex encoded address
126
+ */
127
+ getAccountByEvmAddress(args) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ const { context } = this;
130
+ const { evmAddress } = args;
131
+ // validates `evmAddress`, so the storage query below is never handed a malformed key
132
+ const fallbackAddress = (0, eth_1.ss58FromEthAddress)(evmAddress, context.ss58Format);
133
+ const rawOriginalAccount = yield context.polymeshApi.query.revive.originalAccount(evmAddress);
134
+ const address = rawOriginalAccount.isSome
135
+ ? (0, conversion_1.accountIdToString)(rawOriginalAccount.unwrap())
136
+ : fallbackAddress;
137
+ return (0, internal_2.getAccount)({ address }, context);
138
+ });
139
+ }
102
140
  /**
103
141
  * Return the signing Account, or null if no signing Account has been set
104
142
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AccountManagement.js","sourceRoot":"","sources":["../../../src/api/client/AccountManagement.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA2E;AAG3E,yCAiBoB;AACpB,mCAiBiB;AACjB,mDAAsF;AACtF,+CAM0B;AAE1B;;GAEG;AACH,MAAa,iBAAiB;IAG5B;;OAEG;IACH,YAAY,OAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,aAAa,GAAG,IAAA,gCAAqB,EACxC,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,wBAAa,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EACzE,OAAO,CACR,CAAC;QACF,IAAI,CAAC,uBAAuB,GAAG,IAAA,gCAAqB,EAClD;YACE,mBAAmB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,kCAAuB,oBAAO,IAAI,EAAG;SACpE,EACD,OAAO,CACR,CAAC;QAEF,IAAI,CAAC,oBAAoB,GAAG,IAAA,gCAAqB,EAC/C;YACE,mBAAmB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,+BAAoB,oBAAO,IAAI,EAAG;SACjE,EACD,OAAO,CACR,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,IAAA,gCAAqB,EAM5C;YACE,mBAAmB,EAAE,IAAI,CAAC,EAAE;gBAC1B,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;gBACnC,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC/C,OAAO;wBACL,OAAO;wBACP,WAAW,EAAE;4BACX,MAAM,EAAE,EAAE,IAAI,EAAE,sBAAc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,IAAA,qBAAU,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAEnD,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC,6BAA6B,EAAE,CAAC;YAE/E,MAAM,YAAY,GAAG,IAAA,+BAAkB,EAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACrE,MAAM,QAAQ,GAAG,IAAA,2BAAc,EAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;YAC5D,MAAM,SAAS,GAAG,IAAA,yBAAY,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAEhD,MAAM,cAAc,GAAG;gBACrB,IAAA,kBAAW,EAAC,SAAS,CAAC;gBACtB,YAAY,CAAC,KAAK,EAAE;gBACpB,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;gBACpB,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;gBACrB,IAAA,kBAAW,EAAC,UAAU,CAAC;aACxB,CAAC;YAEF,MAAM,UAAU,GAAG,IAAA,mBAAY,EAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,qBAAc,EAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YAErF,OAAO,OAAO,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;QACtD,CAAC;KAAA;CACF;AA3aD,8CA2aC"}
@@ -1,7 +1,9 @@
1
+ import { AnyJson } from '@polkadot/types/types';
2
+ import { HexString } from '@polkadot/util/types';
1
3
  import BigNumber from 'bignumber.js';
2
4
  import { Account, Context } from '../../internal';
3
5
  import { EventIdEnum, ModuleIdEnum } from '../../middleware/types';
4
- import { EventIdentifier, ExtrinsicDataWithFees, MiddlewareMetadata, NetworkProperties, ProcedureMethod, ProtocolFees, SubCallback, SubmissionDetails, TransactionPayloadInput, TransferPolyxParams, TxTag, UnsubCallback } from '../../types';
6
+ import { EventIdentifier, ExtrinsicDataWithFees, MiddlewareMetadata, NetworkProperties, ProcedureMethod, ProtocolFees, SubCallback, SubmissionDetails, SubmissionOpts, TransactionArgument, TransactionPayloadInput, TransferPolyxParams, TxTag, UnsubCallback } from '../../types';
5
7
  /**
6
8
  * Handles all Network related functionality, including querying for historical events from middleware
7
9
  */
@@ -80,9 +82,84 @@ export declare class Network {
80
82
  /**
81
83
  * Submits a transaction payload with its signature to the chain. `signature` should be hex encoded
82
84
  *
85
+ * @param opts - bounds on how long to wait while broadcasting and tracking the transaction.
86
+ * Defaults to waiting indefinitely
87
+ *
83
88
  * @throws if the signature is not hex encoded
89
+ * @throws `TransactionTimeout` if a bound in `opts` is exceeded. The transaction is not cancelled
90
+ * by this, and can be tracked afterwards with {@link watchTransaction}
91
+ */
92
+ submitTransaction(txPayload: TransactionPayloadInput, signature: string, opts?: SubmissionOpts): Promise<SubmissionDetails>;
93
+ /**
94
+ * Submits a raw, signed Ethereum transaction that carries a Polymesh runtime call through the
95
+ * `revive` pallet's sentinel address. This is the SDK-broadcast submission step, reused
96
+ * here to unlock Fireblocks / KMS / HSM / air-gapped custody flows for Ethereum-derived
97
+ * Accounts: build the payload via
98
+ * {@link base/PolymeshTransactionBase!PolymeshTransactionBase.toEthSignablePayload | transaction.toEthSignablePayload},
99
+ * sign it externally, and submit the raw signed bytes here
100
+ *
101
+ * @param rawSignedTx - the raw signed Ethereum transaction, as returned by an `EthSigner`'s `signTransaction`
102
+ * @param opts - bounds on how long to wait while broadcasting and tracking the transaction.
103
+ * Defaults to waiting indefinitely
104
+ *
105
+ * @throws `TransactionTimeout` if a bound in `opts` is exceeded. The transaction is not cancelled
106
+ * by this, and can be tracked afterwards with {@link watchTransaction}
107
+ */
108
+ submitEthTransaction(rawSignedTx: HexString, opts?: SubmissionOpts): Promise<SubmissionDetails>;
109
+ /**
110
+ * Track a transaction that has already been broadcast, by its hash, and wait for it to be
111
+ * included in a finalized block
112
+ *
113
+ * Complements {@link base/PolymeshTransactionBase!PolymeshTransactionBase.broadcast | transaction.broadcast}
114
+ * and the timeouts on {@link submitTransaction} / {@link submitEthTransaction}: each of those
115
+ * can leave a transaction in flight but untracked. Since this needs nothing but a hash and a
116
+ * block height, tracking can be picked back up in a later session — after a page reload, for
117
+ * instance, where the original handle no longer exists
118
+ *
119
+ * @param args.startingBlock - block height to start searching from. This must be at or before the
120
+ * block the transaction was submitted in, or it will not be found. `broadcast` returns the
121
+ * correct value to persist
122
+ * @param args.txHash - hash of the transaction to look for
123
+ * @param args.isEthTxHash - set to `true` when `txHash` is an Ethereum transaction hash, i.e. the
124
+ * transaction was broadcast by an Ethereum wallet. Those are carried on chain as an unsigned
125
+ * `revive.ethTransact` extrinsic, so they are matched by their payload rather than by the
126
+ * extrinsic hash
127
+ * @param args.timeout - milliseconds to wait before giving up. Defaults to waiting indefinitely
128
+ *
129
+ * @throws `TransactionTimeout` if the transaction is not found in time. It may still be included
130
+ * afterwards — this reports only that the search stopped
131
+ */
132
+ watchTransaction(args: {
133
+ startingBlock: BigNumber;
134
+ txHash: string;
135
+ isEthTxHash?: boolean;
136
+ timeout?: number;
137
+ }): Promise<SubmissionDetails>;
138
+ /**
139
+ * @hidden
140
+ *
141
+ * Broadcast an already-built extrinsic (either the offline-signed native extrinsic, or the
142
+ * bare `revive.ethTransact` wrapper around a raw signed Ethereum transaction) and track it
143
+ * through to finalization
144
+ *
145
+ * @note the bounds in `opts` only apply to the polling path. The subscription path is driven by
146
+ * the node's own status stream, which reports progress unprompted and does not risk waiting on
147
+ * a signer that never responds
148
+ */
149
+ private broadcastExtrinsic;
150
+ /**
151
+ * Decode the SCALE-encoded call carried by a `revive.ethTransact` transaction (or any other
152
+ * Polymesh call), so a dapp can render it next to a wallet's confirmation prompt. Does not
153
+ * fix in-wallet legibility (the wallet still shows raw bytes); it removes the worst of the
154
+ * opacity for a dapp that cares
155
+ *
156
+ * @param hex - SCALE-encoded call, e.g. `transaction.toEthSignablePayload()`'s `transaction.data`
84
157
  */
85
- submitTransaction(txPayload: TransactionPayloadInput, signature: string): Promise<SubmissionDetails>;
158
+ decodeCall(hex: HexString): {
159
+ tag: TxTag;
160
+ args: TransactionArgument[];
161
+ humanReadable: AnyJson;
162
+ };
86
163
  /**
87
164
  * Retrieve a list of events. Can be filtered using parameters
88
165
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Network.d.ts","sourceRoot":"","sources":["../../../src/api/client/Network.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAgC,MAAM,YAAY,CAAC;AAG5E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAS,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAEL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,EACL,aAAa,EACd,MAAM,SAAS,CAAC;AAgBjB;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC;;OAEG;gBACS,OAAO,EAAE,OAAO;IAS5B;;OAEG;IACI,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC;IAI3C;;OAEG;IACI,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;OAEG;IACI,aAAa,IAAI,SAAS;IAIjC;;OAEG;IACU,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAqB/D;;;;OAIG;IACI,eAAe,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAIxE;;OAEG;IACI,kBAAkB,IAAI,OAAO;IAQpC;;;;OAIG;IACI,kBAAkB,IAAI,OAAO,CAAC,SAAS,CAAC;IAE/C;;;;;;;;OAQG;IACI,kBAAkB,CAAC,QAAQ,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,O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EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,KAAK,CAAC,EAAE,SAAS,CAAC;KACnB,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC;IAiCrC;;;;;;OAMG;IACU,oBAAoB,CAAC,IAAI,EAAE;QACtC,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAuFzC;;;;;OAKG;IACI,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAIlE;;;;;;OAMG;IACU,gBAAgB,IAAI,OAAO,CAAC,SAAS,CAAC;IAcnD;;OAEG;IACI,0BAA0B,IAAI,OAAO;IAW5C;;;;OAIG;IACI,oBAAoB,IAAI,OAAO;CAKvC"}
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Network = void 0;
16
16
  const util_1 = require("@polkadot/util");
17
17
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
+ const ethTransaction_1 = require("../../base/ethTransaction");
18
19
  const utils_1 = require("../../base/utils");
19
20
  const internal_1 = require("../../internal");
20
21
  const events_1 = require("../../middleware/queries/events");
@@ -125,10 +126,15 @@ class Network {
125
126
  /**
126
127
  * Submits a transaction payload with its signature to the chain. `signature` should be hex encoded
127
128
  *
129
+ * @param opts - bounds on how long to wait while broadcasting and tracking the transaction.
130
+ * Defaults to waiting indefinitely
131
+ *
128
132
  * @throws if the signature is not hex encoded
133
+ * @throws `TransactionTimeout` if a bound in `opts` is exceeded. The transaction is not cancelled
134
+ * by this, and can be tracked afterwards with {@link watchTransaction}
129
135
  */
130
- submitTransaction(txPayload, signature) {
131
- return __awaiter(this, void 0, void 0, function* () {
136
+ submitTransaction(txPayload_1, signature_1) {
137
+ return __awaiter(this, arguments, void 0, function* (txPayload, signature, opts = {}) {
132
138
  const { context } = this;
133
139
  let payload;
134
140
  let address;
@@ -164,9 +170,100 @@ class Network {
164
170
  });
165
171
  extrinsic.addSignature(address, signature, payload);
166
172
  const transaction = context.polymeshApi.tx(extrinsic);
173
+ return yield this.broadcastExtrinsic(transaction, opts);
174
+ });
175
+ }
176
+ /**
177
+ * Submits a raw, signed Ethereum transaction that carries a Polymesh runtime call through the
178
+ * `revive` pallet's sentinel address. This is the SDK-broadcast submission step, reused
179
+ * here to unlock Fireblocks / KMS / HSM / air-gapped custody flows for Ethereum-derived
180
+ * Accounts: build the payload via
181
+ * {@link base/PolymeshTransactionBase!PolymeshTransactionBase.toEthSignablePayload | transaction.toEthSignablePayload},
182
+ * sign it externally, and submit the raw signed bytes here
183
+ *
184
+ * @param rawSignedTx - the raw signed Ethereum transaction, as returned by an `EthSigner`'s `signTransaction`
185
+ * @param opts - bounds on how long to wait while broadcasting and tracking the transaction.
186
+ * Defaults to waiting indefinitely
187
+ *
188
+ * @throws `TransactionTimeout` if a bound in `opts` is exceeded. The transaction is not cancelled
189
+ * by this, and can be tracked afterwards with {@link watchTransaction}
190
+ */
191
+ submitEthTransaction(rawSignedTx_1) {
192
+ return __awaiter(this, arguments, void 0, function* (rawSignedTx, opts = {}) {
193
+ const { context } = this;
194
+ const transaction = context.polymeshApi.tx.revive.ethTransact(rawSignedTx);
195
+ return yield this.broadcastExtrinsic(transaction, opts);
196
+ });
197
+ }
198
+ /**
199
+ * Track a transaction that has already been broadcast, by its hash, and wait for it to be
200
+ * included in a finalized block
201
+ *
202
+ * Complements {@link base/PolymeshTransactionBase!PolymeshTransactionBase.broadcast | transaction.broadcast}
203
+ * and the timeouts on {@link submitTransaction} / {@link submitEthTransaction}: each of those
204
+ * can leave a transaction in flight but untracked. Since this needs nothing but a hash and a
205
+ * block height, tracking can be picked back up in a later session — after a page reload, for
206
+ * instance, where the original handle no longer exists
207
+ *
208
+ * @param args.startingBlock - block height to start searching from. This must be at or before the
209
+ * block the transaction was submitted in, or it will not be found. `broadcast` returns the
210
+ * correct value to persist
211
+ * @param args.txHash - hash of the transaction to look for
212
+ * @param args.isEthTxHash - set to `true` when `txHash` is an Ethereum transaction hash, i.e. the
213
+ * transaction was broadcast by an Ethereum wallet. Those are carried on chain as an unsigned
214
+ * `revive.ethTransact` extrinsic, so they are matched by their payload rather than by the
215
+ * extrinsic hash
216
+ * @param args.timeout - milliseconds to wait before giving up. Defaults to waiting indefinitely
217
+ *
218
+ * @throws `TransactionTimeout` if the transaction is not found in time. It may still be included
219
+ * afterwards — this reports only that the search stopped
220
+ */
221
+ watchTransaction(args) {
222
+ return __awaiter(this, void 0, void 0, function* () {
223
+ const { context } = this;
224
+ const { startingBlock, txHash, isEthTxHash = false, timeout } = args;
225
+ const matcher = isEthTxHash
226
+ ? (0, ethTransaction_1.ethTransactKeccakMatcher)(txHash)
227
+ : (0, utils_1.extrinsicHashMatcher)(context.createType('Hash', txHash));
228
+ const scanning = context.supportsSubscription()
229
+ ? (0, utils_1.subscribeForTransactionFinalization)(matcher, startingBlock, context)
230
+ : (0, utils_1.pollForTransactionFinalization)(matcher, startingBlock, context);
231
+ const result = yield (0, internal_2.withTimeout)(scanning, timeout, () => new internal_1.PolymeshError({
232
+ code: types_1.ErrorCode.TransactionTimeout,
233
+ message: 'The transaction was not found in a finalized block within the allotted time. It has not been cancelled and may still be included, so this can be retried',
234
+ data: { txHash, startingBlock, timeout },
235
+ }));
236
+ const failureError = (0, utils_1.getExtrinsicFailure)(result);
237
+ if (failureError) {
238
+ throw failureError;
239
+ }
240
+ return {
241
+ blockHash: (0, conversion_1.hashToString)(result.status.asFinalized),
242
+ transactionHash: txHash,
243
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
244
+ transactionIndex: new bignumber_js_1.default(result.txIndex),
245
+ result,
246
+ };
247
+ });
248
+ }
249
+ /**
250
+ * @hidden
251
+ *
252
+ * Broadcast an already-built extrinsic (either the offline-signed native extrinsic, or the
253
+ * bare `revive.ethTransact` wrapper around a raw signed Ethereum transaction) and track it
254
+ * through to finalization
255
+ *
256
+ * @note the bounds in `opts` only apply to the polling path. The subscription path is driven by
257
+ * the node's own status stream, which reports progress unprompted and does not risk waiting on
258
+ * a signer that never responds
259
+ */
260
+ broadcastExtrinsic(transaction, opts) {
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ const { context } = this;
263
+ const { broadcastTimeout, watchTimeout } = opts;
167
264
  const submissionDetails = {
168
265
  blockHash: '',
169
- transactionHash: extrinsic.hash.toString(),
266
+ transactionHash: transaction.hash.toString(),
170
267
  transactionIndex: new bignumber_js_1.default(-1),
171
268
  };
172
269
  if (context.supportsSubscription()) {
@@ -175,7 +272,7 @@ class Network {
175
272
  const { status } = receipt;
176
273
  let isLastCallback = false;
177
274
  let unsubscribing = Promise.resolve();
178
- let extrinsicFailedEvent;
275
+ let failureError;
179
276
  // isCompleted implies status is one of: isFinalized, isInBlock or isError
180
277
  if (receipt.isCompleted) {
181
278
  if (receipt.isInBlock) {
@@ -184,10 +281,14 @@ class Network {
184
281
  // we know that the index has to be set by the time the transaction is included in a block
185
282
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
186
283
  submissionDetails.transactionIndex = new bignumber_js_1.default(receipt.txIndex);
187
- // if the extrinsic failed due to an on-chain error, we should handle it in a special way
188
- [extrinsicFailedEvent] = (0, internal_2.filterEventRecords)(receipt, 'system', 'ExtrinsicFailed', true);
284
+ /*
285
+ * if the extrinsic failed due to an on-chain error, we should handle it in a special
286
+ * way. This also catches `revive.EthExtrinsicRevert`, emitted instead of
287
+ * `system.ExtrinsicFailed` when the transaction was signed by an Ethereum key
288
+ */
289
+ failureError = (0, utils_1.getExtrinsicFailure)(receipt);
189
290
  // extrinsic failed so we can unsubscribe
190
- isLastCallback = !!extrinsicFailedEvent;
291
+ isLastCallback = !!failureError;
191
292
  }
192
293
  else {
193
294
  // isFinalized || isError so we know we can unsubscribe
@@ -203,10 +304,9 @@ class Network {
203
304
  * Primarily for consistent error handling
204
305
  */
205
306
  let finishing = Promise.resolve();
206
- if (extrinsicFailedEvent) {
207
- const { data } = extrinsicFailedEvent;
307
+ if (failureError) {
308
+ const error = failureError;
208
309
  finishing = Promise.all([unsubscribing]).then(() => {
209
- const error = (0, utils_1.handleExtrinsicFailure)(data[0]);
210
310
  reject(error);
211
311
  });
212
312
  }
@@ -226,8 +326,24 @@ class Network {
226
326
  }
227
327
  else {
228
328
  const startingBlock = yield context.getLatestBlock();
229
- yield transaction.send();
230
- const result = yield (0, utils_1.pollForTransactionFinalization)(transaction.hash, startingBlock, context);
329
+ yield (0, internal_2.withTimeout)(transaction.send(), broadcastTimeout, () => new internal_1.PolymeshError({
330
+ code: types_1.ErrorCode.TransactionTimeout,
331
+ message: 'The transaction was not broadcast within the allotted time. It was not cancelled — whether it ends up being submitted is unknown, so check before submitting again, or the same transaction may be submitted twice',
332
+ data: { transactionHash: transaction.hash.toString(), broadcastTimeout },
333
+ }));
334
+ const result = yield (0, internal_2.withTimeout)((0, utils_1.pollForTransactionFinalization)((0, utils_1.extrinsicHashMatcher)(transaction.hash), startingBlock, context), watchTimeout, () => new internal_1.PolymeshError({
335
+ code: types_1.ErrorCode.TransactionTimeout,
336
+ message: 'The transaction was broadcast but was not found in a finalized block within the allotted time. It has not been cancelled and may still be included — it can be tracked by hash with `network.watchTransaction`',
337
+ data: {
338
+ transactionHash: transaction.hash.toString(),
339
+ startingBlock,
340
+ watchTimeout,
341
+ },
342
+ }));
343
+ const failureError = (0, utils_1.getExtrinsicFailure)(result);
344
+ if (failureError) {
345
+ throw failureError;
346
+ }
231
347
  return {
232
348
  blockHash: (0, conversion_1.hashToString)(result.status.asFinalized),
233
349
  transactionHash: (0, conversion_1.hashToString)(transaction.hash),
@@ -237,6 +353,21 @@ class Network {
237
353
  }
238
354
  });
239
355
  }
356
+ /**
357
+ * Decode the SCALE-encoded call carried by a `revive.ethTransact` transaction (or any other
358
+ * Polymesh call), so a dapp can render it next to a wallet's confirmation prompt. Does not
359
+ * fix in-wallet legibility (the wallet still shows raw bytes); it removes the worst of the
360
+ * opacity for a dapp that cares
361
+ *
362
+ * @param hex - SCALE-encoded call, e.g. `transaction.toEthSignablePayload()`'s `transaction.data`
363
+ */
364
+ decodeCall(hex) {
365
+ const { context } = this;
366
+ const tag = (0, conversion_1.transactionHexToTxTag)(hex, context);
367
+ const args = context.getTransactionArguments({ tag });
368
+ const humanReadable = context.createType('Call', hex).toHuman();
369
+ return { tag, args, humanReadable };
370
+ }
240
371
  /**
241
372
  * Retrieve a list of events. Can be filtered using parameters
242
373
  *