@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
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getEthSubmissionStrategy = getEthSubmissionStrategy;
16
+ exports.supportsEip1559 = supportsEip1559;
17
+ exports.dryRunEthTransaction = dryRunEthTransaction;
18
+ exports.buildEthTransactionRequest = buildEthTransactionRequest;
19
+ exports.buildDetachedEthTransactionRequest = buildDetachedEthTransactionRequest;
20
+ exports.calculateEthGasFee = calculateEthGasFee;
21
+ exports.getNativeToEthRatio = getNativeToEthRatio;
22
+ exports.ethTransactKeccakMatcher = ethTransactKeccakMatcher;
23
+ exports.buildSdkBroadcastSubmission = buildSdkBroadcastSubmission;
24
+ exports.buildWalletBroadcastSubmission = buildWalletBroadcastSubmission;
25
+ const util_crypto_1 = require("@polkadot/util-crypto");
26
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
27
+ const utils_1 = require("../base/utils");
28
+ const internal_1 = require("../internal");
29
+ const types_1 = require("../types");
30
+ const conversion_1 = require("../utils/conversion");
31
+ const eth_1 = require("../utils/eth");
32
+ /**
33
+ * @hidden
34
+ *
35
+ * Resolve how to submit for the given signer, from the methods it actually implements.
36
+ *
37
+ * `signTransaction` wins when a signer implements both, since it lets the SDK keep control of the
38
+ * nonce and of the full submission lifecycle
39
+ *
40
+ * @note the returned method is bound to the signer. Callers have to destructure it to narrow the
41
+ * optional property, which would otherwise silently drop `this` for any signer implementing the
42
+ * interface with ordinary class methods rather than arrow function properties
43
+ *
44
+ * @throws if the signer implements neither method
45
+ */
46
+ function getEthSubmissionStrategy(ethSigner) {
47
+ const { signTransaction, sendTransaction } = ethSigner;
48
+ if (signTransaction) {
49
+ return { mode: 'sdkBroadcast', signTransaction: signTransaction.bind(ethSigner) };
50
+ }
51
+ if (sendTransaction) {
52
+ return { mode: 'walletBroadcast', sendTransaction: sendTransaction.bind(ethSigner) };
53
+ }
54
+ throw new internal_1.PolymeshError({
55
+ code: types_1.ErrorCode.General,
56
+ message: 'The attached Ethereum signer implements neither signTransaction nor sendTransaction, so it cannot submit a transaction. Please report this to the Polymesh team',
57
+ });
58
+ }
59
+ /**
60
+ * @hidden
61
+ *
62
+ * Whether to build an EIP-1559 (type 2) transaction for the given signer. Defaults to `true`, so
63
+ * a signer only has to declare the capability when it *cannot* encode type 2
64
+ */
65
+ function supportsEip1559(ethSigner) {
66
+ var _a;
67
+ return (_a = ethSigner.capabilities.eip1559) !== null && _a !== void 0 ? _a : true;
68
+ }
69
+ /**
70
+ * @hidden
71
+ *
72
+ * `0x`-prefixed, minimal (no leading zeros) hex "quantity" encoding, as used throughout the
73
+ * Ethereum JSON-RPC spec for `gas`, `gasPrice`, `chainId`, `nonce`, etc
74
+ */
75
+ function toQuantityHex(value) {
76
+ return `0x${value.integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(16)}`;
77
+ }
78
+ /**
79
+ * @hidden
80
+ *
81
+ * Perform the mandatory dry run pre-flight for a Polymesh call carried through the
82
+ * `revive` pallet's sentinel address. This is the SDK's only pre-flight signal, and doing it
83
+ * over the Substrate connection means a structured error arrives before the wallet is ever
84
+ * consulted
85
+ *
86
+ * Split out from {@link buildEthTransactionRequest} so that fee estimation
87
+ * ({@link base/PolymeshTransactionBase!PolymeshTransactionBase.getTotalFees | getTotalFees}) can
88
+ * use it without requiring an {@link EthSigner} to be attached
89
+ *
90
+ * @throws the parsed dry run error (via {@link utils/eth!parseEthTransactError}) if the dry run itself fails
91
+ */
92
+ function dryRunEthTransaction(context, signingAddress, composedTx) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const { polymeshApi: { call }, } = context;
95
+ const from = (0, eth_1.ethAddressFromSs58)(signingAddress, context.ss58Format);
96
+ const [to, gasPriceRaw] = yield Promise.all([
97
+ context.getEthRuntimePalletsAddress(),
98
+ call.reviveApi.gasPrice(),
99
+ ]);
100
+ const chainId = context.getEthChainId();
101
+ const calldata = composedTx.method.toHex();
102
+ const gasPrice = new bignumber_js_1.default(gasPriceRaw.toString());
103
+ const dryRun = yield call.reviveApi.ethTransactWithConfig({
104
+ from,
105
+ to,
106
+ input: { data: calldata },
107
+ value: 0,
108
+ }, {});
109
+ if (dryRun.isErr) {
110
+ throw (0, eth_1.parseEthTransactError)(dryRun.asErr, context);
111
+ }
112
+ const { ethGas: rawEthGasCodec } = dryRun.asOk;
113
+ const rawEthGas = new bignumber_js_1.default(rawEthGasCodec.toString());
114
+ return { from: from, to: to, calldata, rawEthGas, gasPrice, chainId };
115
+ });
116
+ }
117
+ /**
118
+ * @hidden
119
+ *
120
+ * Build the {@link EthTransactionRequest} that carries a Polymesh runtime call through the
121
+ * `revive` pallet's sentinel address, performing the mandatory dry run pre-flight along the
122
+ * way
123
+ *
124
+ * @throws
125
+ * - the parsed dry run error (via {@link utils/eth!parseEthTransactError}) if the dry run itself fails
126
+ * - `ValidationError` if `nonce` is passed while the signer can only broadcast, and so owns the
127
+ * nonce itself
128
+ */
129
+ function buildEthTransactionRequest(params) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const { context, signingAddress, composedTx, ethSigner, nonce: nonceOverride, gasMultiplier = new bignumber_js_1.default(1), } = params;
132
+ const { mode } = getEthSubmissionStrategy(ethSigner);
133
+ if (mode === 'walletBroadcast' && nonceOverride) {
134
+ throw new internal_1.PolymeshError({
135
+ code: types_1.ErrorCode.ValidationError,
136
+ message: 'The nonce cannot be set explicitly when the Ethereum signer broadcasts the transaction itself. The wallet is responsible for nonce management in this mode',
137
+ });
138
+ }
139
+ const { from, to, calldata, rawEthGas, gasPrice, chainId } = yield dryRunEthTransaction(context, signingAddress, composedTx);
140
+ const gasToUse = bignumber_js_1.default.max(rawEthGas.multipliedBy(gasMultiplier).integerValue(bignumber_js_1.default.ROUND_CEIL), rawEthGas);
141
+ let nonce;
142
+ if (mode === 'sdkBroadcast') {
143
+ if (nonceOverride) {
144
+ nonce = toQuantityHex(nonceOverride);
145
+ }
146
+ else {
147
+ const { polymeshApi: { call }, } = context;
148
+ const onChainNonce = yield call.reviveApi.nonce(from);
149
+ nonce = toQuantityHex(new bignumber_js_1.default(onChainNonce.toString()));
150
+ }
151
+ }
152
+ const eip1559 = supportsEip1559(ethSigner);
153
+ const request = Object.assign(Object.assign({ from,
154
+ to, data: calldata, value: '0x0', gas: toQuantityHex(gasToUse), chainId: toQuantityHex(chainId) }, (nonce ? { nonce } : {})), (eip1559
155
+ ? {
156
+ type: '0x2',
157
+ maxFeePerGas: toQuantityHex(gasPrice),
158
+ maxPriorityFeePerGas: toQuantityHex(new bignumber_js_1.default(0)),
159
+ }
160
+ : {
161
+ type: '0x0',
162
+ gasPrice: toQuantityHex(gasPrice),
163
+ }));
164
+ return { request, rawEthGas, gasPrice };
165
+ });
166
+ }
167
+ /**
168
+ * @hidden
169
+ *
170
+ * Build an {@link EthTransactionRequest} for detached/custody signing
171
+ * ({@link base/PolymeshTransactionBase!PolymeshTransactionBase.toEthSignablePayload | toEthSignablePayload}),
172
+ * where there is no {@link EthSigner} attached to consult for routing. The nonce is always
173
+ * resolved (either the caller's `ProcedureOpts.nonce`, or fetched on-chain), since a detached
174
+ * signer cannot own the nonce the way a broadcasting wallet does
175
+ */
176
+ function buildDetachedEthTransactionRequest(context, signingAddress, composedTx, eip1559, nonceOverride) {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ const { from, to, calldata, rawEthGas, gasPrice, chainId } = yield dryRunEthTransaction(context, signingAddress, composedTx);
179
+ let nonce;
180
+ if (nonceOverride) {
181
+ nonce = toQuantityHex(nonceOverride);
182
+ }
183
+ else {
184
+ const { polymeshApi: { call }, } = context;
185
+ const onChainNonce = yield call.reviveApi.nonce(from);
186
+ nonce = toQuantityHex(new bignumber_js_1.default(onChainNonce.toString()));
187
+ }
188
+ return Object.assign({ from,
189
+ to, data: calldata, value: '0x0', gas: toQuantityHex(rawEthGas), chainId: toQuantityHex(chainId), nonce }, (eip1559
190
+ ? {
191
+ type: '0x2',
192
+ maxFeePerGas: toQuantityHex(gasPrice),
193
+ maxPriorityFeePerGas: toQuantityHex(new bignumber_js_1.default(0)),
194
+ }
195
+ : {
196
+ type: '0x0',
197
+ gasPrice: toQuantityHex(gasPrice),
198
+ }));
199
+ });
200
+ }
201
+ /**
202
+ * @hidden
203
+ *
204
+ * Derive the network fee for a transaction submitted through the `revive` pallet's sentinel
205
+ * address:
206
+ *
207
+ * ```
208
+ * feeInBaseUnits = ethGas * gasPrice / nativeToEthRatio
209
+ * ```
210
+ *
211
+ * The result is returned as a **display POLYX value**, i.e. shifted down by the chain's 6
212
+ * decimals, so that it is directly comparable with everything else in `PayingAccountFees` —
213
+ * protocol fees and Account balances both arrive that way, via `balanceToBigNumber`. Returning
214
+ * base units here would make the Ethereum path report fees 10^6 too large, and every fee check
215
+ * against a balance would fail
216
+ *
217
+ * @note the rounding is applied to whole base units *before* the shift, since a fee cannot be a
218
+ * fraction of a base unit
219
+ * @note this is a slight, safe overestimate of the fee the chain actually charges — measured at
220
+ * 1.008-1.011x. It does **not** include protocol fees, which are charged separately and must
221
+ * still be summed in by the caller
222
+ */
223
+ function calculateEthGasFee(rawEthGas, gasPrice, nativeToEthRatio) {
224
+ return rawEthGas
225
+ .multipliedBy(gasPrice)
226
+ .dividedBy(nativeToEthRatio)
227
+ .integerValue(bignumber_js_1.default.ROUND_CEIL)
228
+ .shiftedBy(-6);
229
+ }
230
+ /**
231
+ * @hidden
232
+ *
233
+ * Retrieve `consts.revive.nativeToEthRatio` as a `BigNumber`
234
+ */
235
+ function getNativeToEthRatio(context) {
236
+ return (0, conversion_1.u64ToBigNumber)(context.polymeshApi.consts.revive.nativeToEthRatio);
237
+ }
238
+ /**
239
+ * @hidden
240
+ *
241
+ * Build the predicate that correlates an Ethereum transaction hash (returned by a broadcasting
242
+ * wallet's `sendTransaction`) to the Substrate extrinsic that carries it:
243
+ *
244
+ * ```
245
+ * extrinsic.method.section === 'revive' &&
246
+ * extrinsic.method.method === 'ethTransact' &&
247
+ * keccakAsHex(extrinsic.args[0].toU8a(true)) === ethTxHash
248
+ * ```
249
+ *
250
+ * This is deterministic, not a heuristic: the Ethereum transaction hash is `keccak256` of the raw
251
+ * signed transaction, and those exact bytes are the `payload` argument of the `revive.ethTransact`
252
+ * extrinsic recorded in the block — byte-identical, including in blocks carrying several
253
+ * Ethereum extrinsics
254
+ */
255
+ function ethTransactKeccakMatcher(ethTxHash) {
256
+ const normalizedHash = ethTxHash.toLowerCase();
257
+ return (extrinsic) => {
258
+ if (extrinsic.method.section !== 'revive' || extrinsic.method.method !== 'ethTransact') {
259
+ return false;
260
+ }
261
+ const [payload] = extrinsic.args;
262
+ if (!payload) {
263
+ return false;
264
+ }
265
+ return (0, util_crypto_1.keccakAsHex)(payload.toU8a(true)).toLowerCase() === normalizedHash;
266
+ };
267
+ }
268
+ /**
269
+ * @hidden
270
+ *
271
+ * The SDK holds the raw signed bytes and submits them itself via
272
+ * `api.tx.revive.ethTransact(raw)`. Since this is a *bare* (unsigned) extrinsic — the
273
+ * signature is embedded in the Ethereum payload itself — it is broadcast with `.send()`
274
+ * rather than `.signAndSend()`, exactly like the offline-signed path in
275
+ * `Network.submitTransaction`. From here on, the lifecycle is identical to the native path:
276
+ * same `ISubmittableResult` status transitions, same `outer.hash` semantics
277
+ */
278
+ function buildSdkBroadcastSubmission(context, rawSignedTx) {
279
+ const outer = context.polymeshApi.tx.revive.ethTransact(rawSignedTx);
280
+ return {
281
+ subscription: {
282
+ subscribe: callback => outer.send(callback),
283
+ getTxHash: () => outer.hash.toString(),
284
+ },
285
+ polling: {
286
+ send: () => __awaiter(this, void 0, void 0, function* () {
287
+ const txHash = yield outer.send();
288
+ return { txHash: txHash.toString(), matcher: (0, utils_1.extrinsicHashMatcher)(txHash) };
289
+ }),
290
+ },
291
+ };
292
+ }
293
+ /**
294
+ * @hidden
295
+ *
296
+ * The wallet signs AND broadcasts, returning the Ethereum transaction hash.
297
+ * The SDK never submits anything itself here, so there is no extrinsic-status subscription
298
+ * channel to attach to — the only way to locate the result is to scan blocks for the matching
299
+ * `revive.ethTransact` extrinsic (via {@link ethTransactKeccakMatcher}).
300
+ *
301
+ * The block scan is shared with the native path rather than duplicated: the same
302
+ * {@link ExtrinsicMatcher} drives both, so there is one implementation and one set of tests
303
+ *
304
+ * @param sendTransaction - the signer's `sendTransaction`, resolved by the caller. Taking the
305
+ * bound method rather than the signer is what makes this total: reaching here at all means
306
+ * {@link getEthSubmissionStrategy} found the method, so there is no "signer said it could broadcast
307
+ * but cannot" case left to guard against
308
+ */
309
+ function buildWalletBroadcastSubmission(sendTransaction, request) {
310
+ return {
311
+ send: () => __awaiter(this, void 0, void 0, function* () {
312
+ const ethTxHash = yield sendTransaction(request);
313
+ return { txHash: ethTxHash, matcher: ethTransactKeccakMatcher(ethTxHash) };
314
+ }),
315
+ };
316
+ }
317
+ //# sourceMappingURL=ethTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ethTransaction.js","sourceRoot":"","sources":["../../src/base/ethTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAuDA,4DAgBC;AAQD,0CAEC;AA4ED,oDAoCC;AAcD,gEAqEC;AAWD,gFA2CC;AAwBD,gDAUC;AAOD,kDAEC;AAmBD,4DAgBC;AAYD,kEAmBC;AAkBD,wEAWC;AAhdD,uDAAoD;AACpD,gEAAqC;AAGrC,wCAAsE;AACtE,yCAAoD;AACpD,mCAAoC;AAEpC,mDAAoD;AACpD,qCAAwE;AA4BxE;;;;;;;;;;;;;GAaG;AACH,SAAgB,wBAAwB,CAAC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,GAAG,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAErE,OAAO;QACL,YAAY,EAAE;YACZ,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC3C,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;SACvC;QACD,OAAO,EAAE;YACP,IAAI,EAAE,GAAiE,EAAE;gBACvE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;gBAElC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAA,4BAAoB,EAAC,MAAM,CAAC,EAAE,CAAC;YAC9E,CAAC,CAAA;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,8BAA8B,CAC5C,eAA0D,EAC1D,OAA8B;IAE9B,OAAO;QACL,IAAI,EAAE,GAAiE,EAAE;YACvE,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;YAEjD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7E,CAAC,CAAA;KACF,CAAC;AACJ,CAAC"}
package/base/types.d.ts CHANGED
@@ -1,17 +1,60 @@
1
1
  import { SignerPayloadJSON, SignerPayloadRaw, TypeDef } from '@polkadot/types/types';
2
2
  import { HexString } from '@polkadot/util/types';
3
+ import { EthTransactionRequest } from '@polymeshassociation/signing-manager-types';
3
4
  import BigNumber from 'bignumber.js';
4
5
  import { PolymeshError as PolymeshErrorClass } from '../base/PolymeshError';
5
6
  import { PolymeshTransaction as PolymeshTransactionClass } from '../base/PolymeshTransaction';
6
7
  import { PolymeshTransactionBatch as PolymeshTransactionBatchClass } from '../base/PolymeshTransactionBatch';
7
8
  import { Account } from '../internal';
8
- import { Fees, TxData } from '../types';
9
+ import { Fees, TxData, TxTag } from '../types';
9
10
  /**
10
11
  * Apply the {@link TxData} type to all args in an array
11
12
  */
12
13
  export type MapTxData<ArgsArray extends unknown[][]> = {
13
14
  [K in keyof ArgsArray]: ArgsArray[K] extends unknown[] ? TxData<ArgsArray[K]> : never;
14
15
  };
16
+ /**
17
+ * Handle to a transaction that has been broadcast but is not being tracked. Returned by
18
+ * {@link base/PolymeshTransactionBase!PolymeshTransactionBase.broadcast | transaction.broadcast},
19
+ * which is `run` split at its natural seam: the transaction is on its way to the chain, and
20
+ * whether to wait for it is now the caller's decision
21
+ */
22
+ export interface TransactionBroadcastHandle<ReturnValue> {
23
+ /**
24
+ * the hash the transaction can be looked up by. Normally the Substrate extrinsic hash, but the
25
+ * Ethereum transaction hash when an Ethereum wallet broadcast it, since that is the handle the
26
+ * user has and can find in a block explorer
27
+ */
28
+ txHash: string;
29
+ /**
30
+ * the Ethereum transaction hash, set only when an Ethereum wallet broadcast the transaction
31
+ * itself. `undefined` otherwise
32
+ */
33
+ ethTxHash?: string;
34
+ /**
35
+ * the block height the search for this transaction has to start from. Persist this alongside
36
+ * `txHash` to resume tracking later via
37
+ * {@link api/client/Network!Network.watchTransaction | network.watchTransaction}, for example
38
+ * after a page reload, when `watch` itself is long gone
39
+ */
40
+ startingBlock: BigNumber;
41
+ /**
42
+ * Wait for the transaction to be included in a finalized block and return the same value
43
+ * `run` would have returned
44
+ *
45
+ * Safe to retry if it times out — nothing is resubmitted, the search simply resumes. Calling it
46
+ * while a previous call is still in flight throws
47
+ *
48
+ * @param opts.timeout - milliseconds to wait before giving up. Overrides `submission.watchTimeout`
49
+ * from the Procedure options. Defaults to waiting indefinitely
50
+ *
51
+ * @throws `TransactionTimeout` if the transaction is not found in time. The transaction was still
52
+ * broadcast and may yet be included — this reports only that the SDK stopped looking
53
+ */
54
+ watch: (opts?: {
55
+ timeout?: number;
56
+ }) => Promise<ReturnValue>;
57
+ }
15
58
  export declare enum TransactionStatus {
16
59
  /**
17
60
  * the transaction is prepped to run
@@ -193,4 +236,26 @@ export type TransactionPayloadInput = TransactionPayload | TransactionPayload['p
193
236
  export type PolymeshTransaction<ReturnValue = unknown, TransformedReturnValue = ReturnValue, Args extends unknown[] | [] = unknown[]> = PolymeshTransactionClass<ReturnValue, TransformedReturnValue, Args>;
194
237
  export type PolymeshTransactionBatch<ReturnValue = unknown, TransformedReturnValue = ReturnValue, Args extends unknown[][] = unknown[][]> = PolymeshTransactionBatchClass<ReturnValue, TransformedReturnValue, Args>;
195
238
  export type PolymeshError = PolymeshErrorClass;
239
+ export { EthSigner, EthSignerCapabilities, EthSigningManager, } from '@polymeshassociation/signing-manager-types';
240
+ export { EthTransactionRequest };
241
+ /**
242
+ * A representation of an Ethereum transaction intended for offline/detached signing, along with
243
+ * the decoded call for display
244
+ */
245
+ export interface EthTransactionPayload {
246
+ /**
247
+ * the parameters that would be passed to `EthSigner.signTransaction` / `sendTransaction`
248
+ *
249
+ * @note every field is 0x-prefixed hex, never a number or bigint. ethers and viem both need it
250
+ * converted first — `@polymeshassociation/eth-signing-manager` exports `toEthersTransaction` /
251
+ * `toViemTransaction` for that, usable without the manager itself
252
+ */
253
+ transaction: EthTransactionRequest;
254
+ /** the transaction tag identifying the underlying Polymesh call */
255
+ tag: TxTag;
256
+ /** argument metadata for the underlying Polymesh call */
257
+ args: TransactionArgument[];
258
+ /** additional information attached to the payload, such as IDs or memos about the transaction */
259
+ metadata: Record<string, string>;
260
+ }
196
261
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAA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AAG,WAAW,EACpC,IAAI,SAAS,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,IACrC,wBAAwB,CAAC,WAAW,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC;AACxE,MAAM,MAAM,wBAAwB,CAClC,WAAW,GAAG,OAAO,EACrB,sBAAsB,GAAG,WAAW,EACpC,IAAI,SAAS,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,IACpC,6BAA6B,CAAC,WAAW,EAAE,sBAAsB,EAAE,IAAI,CAAC,CAAC;AAC7E,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAY/C,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,WAAW,EAAE,qBAAqB,CAAC;IACnC,mEAAmE;IACnE,GAAG,EAAE,KAAK,CAAC;IACX,yDAAyD;IACzD,IAAI,EAAE,mBAAmB,EAAE,CAAC;IAC5B,iGAAiG;IACjG,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
package/base/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":";AAAA,+DAA+D;;;AAmB/D,IAAY,iBAsCX;AAtCD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,kCAAa,CAAA;IACb;;OAEG;IACH,8CAAyB,CAAA;IACzB;;OAEG;IACH,wCAAmB,CAAA;IACnB;;OAEG;IACH,wCAAmB,CAAA;IACnB;;OAEG;IACH,sCAAiB,CAAA;IACjB;;OAEG;IACH,0CAAqB,CAAA;IACrB;;OAEG;IACH,4CAAuB,CAAA;IACvB;;OAEG;IACH,sCAAiB,CAAA;IACjB;;;OAGG;IACH,wCAAmB,CAAA;AACrB,CAAC,EAtCW,iBAAiB,iCAAjB,iBAAiB,QAsC5B;AAED,IAAY,uBAeX;AAfD,WAAY,uBAAuB;IACjC,sCAAW,CAAA;IACX,8CAAmB,CAAA;IACnB,wCAAa,CAAA;IACb,8CAAmB,CAAA;IACnB,4CAAiB,CAAA;IACjB,8CAAmB,CAAA;IACnB,wCAAa,CAAA;IACb,0CAAe,CAAA;IACf,0CAAe,CAAA;IACf,oDAAyB,CAAA;IACzB,gDAAqB,CAAA;IACrB,4CAAiB,CAAA;IACjB,8CAAmB,CAAA;IACnB,wCAAa,CAAA;AACf,CAAC,EAfW,uBAAuB,uCAAvB,uBAAuB,QAelC;AA0CD;;GAEG;AACH,IAAY,iBAmBX;AAnBD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,wCAAmB,CAAA;IACnB;;;;OAIG;IACH,oCAAe,CAAA;IACf;;OAEG;IACH,sCAAiB,CAAA;IACjB;;OAEG;IACH,wDAAmC,CAAA;AACrC,CAAC,EAnBW,iBAAiB,iCAAjB,iBAAiB,QAmB5B"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/base/types.ts"],"names":[],"mappings":";AAAA,+DAA+D;;;AAgE/D,IAAY,iBAsCX;AAtCD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,kCAAa,CAAA;IACb;;OAEG;IACH,8CAAyB,CAAA;IACzB;;OAEG;IACH,wCAAmB,CAAA;IACnB;;OAEG;IACH,wCAAmB,CAAA;IACnB;;OAEG;IACH,sCAAiB,CAAA;IACjB;;OAEG;IACH,0CAAqB,CAAA;IACrB;;OAEG;IACH,4CAAuB,CAAA;IACvB;;OAEG;IACH,sCAAiB,CAAA;IACjB;;;OAGG;IACH,wCAAmB,CAAA;AACrB,CAAC,EAtCW,iBAAiB,iCAAjB,iBAAiB,QAsC5B;AAED,IAAY,uBAeX;AAfD,WAAY,uBAAuB;IACjC,sCAAW,CAAA;IACX,8CAAmB,CAAA;IACnB,wCAAa,CAAA;IACb,8CAAmB,CAAA;IACnB,4CAAiB,CAAA;IACjB,8CAAmB,CAAA;IACnB,wCAAa,CAAA;IACb,0CAAe,CAAA;IACf,0CAAe,CAAA;IACf,oDAAyB,CAAA;IACzB,gDAAqB,CAAA;IACrB,4CAAiB,CAAA;IACjB,8CAAmB,CAAA;IACnB,wCAAa,CAAA;AACf,CAAC,EAfW,uBAAuB,uCAAvB,uBAAuB,QAelC;AA0CD;;GAEG;AACH,IAAY,iBAmBX;AAnBD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,wCAAmB,CAAA;IACnB;;;;OAIG;IACH,oCAAe,CAAA;IACf;;OAEG;IACH,sCAAiB,CAAA;IACjB;;OAEG;IACH,wDAAmC,CAAA;AACrC,CAAC,EAnBW,iBAAiB,iCAAjB,iBAAiB,QAmB5B"}
package/base/utils.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { SubmittableResult } from '@polkadot/api';
2
+ import { GenericExtrinsic } from '@polkadot/types';
2
3
  import { DispatchError, Hash } from '@polkadot/types/interfaces';
3
4
  import { SpRuntimeDispatchError } from '../../node_modules/@polymeshassociation/polymesh-types/polkadot/types-lookup';
4
- import { TypeDef } from '@polkadot/types/types';
5
+ import { ISubmittableResult, TypeDef } from '@polkadot/types/types';
5
6
  import { BigNumber } from 'bignumber.js';
6
7
  import { Context, PolymeshError } from '../internal';
7
8
  import { TransactionArgument, TxTag } from '../types';
@@ -11,25 +12,73 @@ export declare const dispatchErrorToMessage: (error: SpRuntimeDispatchError | Di
11
12
  * @hidden
12
13
  */
13
14
  export declare const handleExtrinsicFailure: (error: SpRuntimeDispatchError, data?: Record<string, unknown>) => PolymeshError;
14
- export declare const handleTransactionSubmissionError: (err: Error) => PolymeshError;
15
15
  /**
16
16
  * @hidden
17
17
  *
18
- * given a transaction hash this will poll the chain until it is included in a finalized block
18
+ * Inspect a transaction receipt for an on-chain failure and return the corresponding error, or
19
+ * `undefined` if the transaction succeeded
20
+ *
21
+ * Two distinct failure shapes feed into the same {@link handleExtrinsicFailure}:
22
+ *
23
+ * - `system.ExtrinsicFailed`, the native path's failure signal
24
+ * - `revive.EthExtrinsicRevert`, emitted instead on the Ethereum signing path. There, the outer
25
+ * `revive.ethTransact` extrinsic still emits `system.ExtrinsicSuccess` even when the inner
26
+ * dispatch failed, so this check must run (and take priority) before the receipt is otherwise
27
+ * treated as a success
28
+ */
29
+ export declare const getExtrinsicFailure: (receipt: ISubmittableResult) => PolymeshError | undefined;
30
+ export declare const handleTransactionSubmissionError: (err: Error) => PolymeshError;
31
+ /**
32
+ * @hidden
19
33
  *
20
- * @note this method should only be used when there is no subscription support for efficiency
34
+ * Predicate used to recognize a submitted transaction within a block's body. The native path
35
+ * matches on the extrinsic hash, while Ethereum signed transactions match on the keccak hash
36
+ * of the `revive.ethTransact` payload (since the extrinsic itself is unsigned and its hash is
37
+ * not known to the wallet that broadcast it)
38
+ */
39
+ export type ExtrinsicMatcher = (extrinsic: GenericExtrinsic) => boolean;
40
+ /**
41
+ * @hidden
21
42
  *
22
- * @throws if transaction is not found after a certain amount of time
43
+ * Build a matcher that recognizes an extrinsic by its hash. This is the native submission path
44
+ */
45
+ export declare const extrinsicHashMatcher: (txHash: Hash) => ExtrinsicMatcher;
46
+ /**
47
+ * @hidden
23
48
  *
24
- * @param txHash The hash of the transaction
25
- * @param startingBlock The block number from before the transaction was submitted
26
- * @param context
27
- * @param pollOptions Controls max time to poll, defaults should be OK (finalization takes ~15 seconds)
28
- * @returns
49
+ * Where a transaction was found, reported as soon as it is included in a block — before that
50
+ * block is finalized
29
51
  */
30
- export declare const pollForTransactionFinalization: (txHash: Hash, startingBlock: BigNumber, context: Context, pollOptions?: {
52
+ export interface TransactionInclusionInfo {
53
+ blockHash: string;
54
+ blockNumber: BigNumber;
55
+ txIndex: number;
56
+ }
57
+ export declare const pollForTransactionFinalization: (matcher: ExtrinsicMatcher, startingBlock: BigNumber, context: Context, pollOptions?: {
31
58
  delayMs: number;
32
59
  maxAttempts: number;
60
+ }, onInBlock?: (info: TransactionInclusionInfo) => void) => Promise<SubmittableResult>;
61
+ /**
62
+ * @hidden
63
+ *
64
+ * Locate a submitted transaction by subscribing to the chain's blocks, rather than polling for
65
+ * them. Preferred whenever the connection supports subscriptions: inclusion is reported the
66
+ * moment the block arrives instead of on the next poll tick, and it removes a repeating
67
+ * `getHeader`/`getBlock` cycle per in-flight transaction
68
+ *
69
+ * Two independent scans run off two subscriptions:
70
+ *
71
+ * - **new heads** are advisory. They exist only to report inclusion early, via `onInBlock`. A
72
+ * block seen here may still be re-organised away, which is harmless because nothing but a
73
+ * progress callback depends on it
74
+ * - **finalized heads** are authoritative. The resolved result always comes from a finalized
75
+ * block, so a re-org cannot produce a wrong result — the transaction simply will not be found
76
+ * at that height on the canonical chain, and the scan continues
77
+ *
78
+ * @throws if the transaction is not found within `maxFinalizedBlocks` finalized blocks
79
+ */
80
+ export declare const subscribeForTransactionFinalization: (matcher: ExtrinsicMatcher, startingBlock: BigNumber, context: Context, onInBlock?: (info: TransactionInclusionInfo) => void, { maxFinalizedBlocks }?: {
81
+ maxFinalizedBlocks: number;
33
82
  }) => Promise<SubmittableResult>;
34
83
  /**
35
84
  * @hidden
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/base/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAe,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAiB,OAAO,EAAe,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAOL,mBAAmB,EAEnB,KAAK,EACN,MAAM,SAAS,CAAC;AA8CjB,eAAO,MAAM,WAAW,GAAI,SAAS,OAA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