@pushchain/core 6.0.20 → 6.0.21

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 (111) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/package.json +1 -1
  3. package/src/lib/cache/cache.js +2 -0
  4. package/src/lib/constants/abi/index.d.ts +1 -0
  5. package/src/lib/constants/abi/index.js +8 -1
  6. package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
  7. package/src/lib/constants/abi/pc20.evm.js +150 -0
  8. package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
  9. package/src/lib/constants/abi/prc20.evm.js +97 -0
  10. package/src/lib/constants/abi/universalGatewayV0.json +1 -1
  11. package/src/lib/constants/chain.js +38 -8
  12. package/src/lib/constants/selectors.js +2 -2
  13. package/src/lib/constants/tokens.js +4 -3
  14. package/src/lib/formatters.js +16 -6
  15. package/src/lib/generated/uexecutor/v1/query.js +2 -4
  16. package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
  17. package/src/lib/generated/uexecutor/v1/types.js +90 -47
  18. package/src/lib/generated/uexecutor/v2/query.js +2 -4
  19. package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
  20. package/src/lib/generated/uexecutor/v2/types.js +49 -33
  21. package/src/lib/generated/v1/tx.js +30 -37
  22. package/src/lib/index.d.ts +3 -0
  23. package/src/lib/index.js +21 -3
  24. package/src/lib/internal/buffer.js +1 -2
  25. package/src/lib/orchestrator/cea-utils.js +73 -83
  26. package/src/lib/orchestrator/internals/account-manager.js +130 -139
  27. package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
  28. package/src/lib/orchestrator/internals/cascade.js +1184 -1059
  29. package/src/lib/orchestrator/internals/confirmation.js +138 -148
  30. package/src/lib/orchestrator/internals/error-decoder.js +1 -1
  31. package/src/lib/orchestrator/internals/errors.js +12 -3
  32. package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
  33. package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
  34. package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
  35. package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
  36. package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
  37. package/src/lib/orchestrator/internals/execute-standard.js +339 -342
  38. package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
  39. package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
  40. package/src/lib/orchestrator/internals/gateway-client.js +102 -103
  41. package/src/lib/orchestrator/internals/helpers.js +30 -27
  42. package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
  43. package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
  44. package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
  45. package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
  46. package/src/lib/orchestrator/internals/payload-builder.js +119 -100
  47. package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
  48. package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
  49. package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
  50. package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
  51. package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
  52. package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
  53. package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
  54. package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
  55. package/src/lib/orchestrator/internals/pc20/export.js +412 -0
  56. package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
  57. package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
  58. package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
  59. package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
  60. package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
  61. package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
  62. package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
  63. package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
  64. package/src/lib/orchestrator/internals/preflight.js +1 -1
  65. package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
  66. package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
  67. package/src/lib/orchestrator/internals/quote.js +90 -94
  68. package/src/lib/orchestrator/internals/rescue.js +76 -79
  69. package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
  70. package/src/lib/orchestrator/internals/response-builder.js +817 -701
  71. package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
  72. package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
  73. package/src/lib/orchestrator/internals/signing.js +78 -83
  74. package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
  75. package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
  76. package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
  77. package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
  78. package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
  79. package/src/lib/orchestrator/internals/svm-rent.js +163 -141
  80. package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
  81. package/src/lib/orchestrator/internals/uea-manager.js +89 -86
  82. package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
  83. package/src/lib/orchestrator/orchestrator.js +217 -200
  84. package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
  85. package/src/lib/orchestrator/orchestrator.types.js +19 -0
  86. package/src/lib/orchestrator/payload-builders.d.ts +2 -2
  87. package/src/lib/orchestrator/payload-builders.js +26 -24
  88. package/src/lib/orchestrator/route-detector.js +26 -9
  89. package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
  90. package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
  91. package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
  92. package/src/lib/price-fetch/price-fetch.js +67 -68
  93. package/src/lib/progress-hook/progress-hook.js +124 -72
  94. package/src/lib/push-chain/push-chain.js +171 -153
  95. package/src/lib/push-client/push-client.js +223 -237
  96. package/src/lib/universal/account/account.js +349 -365
  97. package/src/lib/universal/signer/signer.js +306 -294
  98. package/src/lib/universal-tx-detector/auto-detect.js +55 -60
  99. package/src/lib/universal-tx-detector/cascade.js +160 -172
  100. package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
  101. package/src/lib/universal-tx-detector/classify.js +2 -3
  102. package/src/lib/universal-tx-detector/detector-svm.js +139 -147
  103. package/src/lib/universal-tx-detector/detector.js +145 -157
  104. package/src/lib/universal-tx-detector/normalize.js +7 -7
  105. package/src/lib/utils/external-tx-hash.js +1 -2
  106. package/src/lib/utils.d.ts +44 -0
  107. package/src/lib/utils.js +762 -683
  108. package/src/lib/vm-client/evm-client.js +186 -202
  109. package/src/lib/vm-client/svm-client.d.ts +1 -1
  110. package/src/lib/vm-client/svm-client.js +220 -224
  111. package/src/lib/vm-client/vm-client.types.d.ts +14 -2
@@ -10,7 +10,6 @@ exports.getUEANonce = getUEANonce;
10
10
  exports.getUeaNonceForExecution = getUeaNonceForExecution;
11
11
  exports.getUeaStatusAndNonce = getUeaStatusAndNonce;
12
12
  exports.fetchUEAVersion = fetchUEAVersion;
13
- const tslib_1 = require("tslib");
14
13
  const bs58_1 = require("../../internal/bs58");
15
14
  const viem_1 = require("viem");
16
15
  const factoryV1_1 = require("../../constants/abi/factoryV1");
@@ -63,102 +62,106 @@ function computeUEAOffchain(ctx) {
63
62
  // ============================================================================
64
63
  // On-chain UEA Computation
65
64
  // ============================================================================
66
- function computeUEA(ctx) {
67
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
68
- const { chain, address } = ctx.universalSigner.account;
69
- const { vm, chainId } = chain_1.CHAIN_INFO[chain];
70
- if ((0, helpers_1.isPushChain)(chain)) {
71
- throw new Error('UEA cannot be computed for a Push Chain Address');
72
- }
73
- const computedAddress = yield ctx.pushClient.readContract({
74
- address: ctx.pushClient.pushChainInfo.factoryAddress,
75
- abi: factoryV1_1.FACTORY_V1,
76
- functionName: 'computeUEA',
77
- args: [
78
- {
79
- chainNamespace: chain_1.VM_NAMESPACE[vm],
80
- chainId,
81
- owner: vm === enums_1.VM.EVM
82
- ? address
83
- : vm === enums_1.VM.SVM
84
- ? (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)))
85
- : address,
86
- },
87
- ],
88
- });
89
- const byteCode = yield ctx.pushClient.publicClient.getCode({
90
- address: computedAddress,
91
- });
92
- return { address: computedAddress, deployed: byteCode !== undefined };
65
+ async function computeUEA(ctx) {
66
+ const { chain, address } = ctx.universalSigner.account;
67
+ const { vm, chainId } = chain_1.CHAIN_INFO[chain];
68
+ if ((0, helpers_1.isPushChain)(chain)) {
69
+ throw new Error('UEA cannot be computed for a Push Chain Address');
70
+ }
71
+ const computedAddress = await ctx.pushClient.readContract({
72
+ address: ctx.pushClient.pushChainInfo.factoryAddress,
73
+ abi: factoryV1_1.FACTORY_V1,
74
+ functionName: 'computeUEA',
75
+ args: [
76
+ {
77
+ chainNamespace: chain_1.VM_NAMESPACE[vm],
78
+ chainId,
79
+ owner: vm === enums_1.VM.EVM
80
+ ? address
81
+ : vm === enums_1.VM.SVM
82
+ ? (0, viem_1.bytesToHex)(new Uint8Array(bs58_1.bs58.decode(address)))
83
+ : address,
84
+ },
85
+ ],
93
86
  });
87
+ const byteCode = await ctx.pushClient.publicClient.getCode({
88
+ address: computedAddress,
89
+ });
90
+ return { address: computedAddress, deployed: byteCode !== undefined };
94
91
  }
95
92
  // ============================================================================
96
93
  // UEA Nonce
97
94
  // ============================================================================
98
- function getUEANonce(ctx, address) {
99
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
100
- const chain = ctx.universalSigner.account.chain;
101
- const { vm } = chain_1.CHAIN_INFO[chain];
102
- switch (vm) {
103
- case enums_1.VM.EVM:
104
- return ctx.pushClient.readContract({
105
- address,
106
- abi: uea_evm_1.UEA_EVM,
107
- functionName: 'nonce',
108
- });
109
- case enums_1.VM.SVM:
110
- return ctx.pushClient.readContract({
111
- address,
112
- abi: uea_svm_1.UEA_SVM,
113
- functionName: 'nonce',
114
- });
115
- default:
116
- throw new Error(`Unsupported VM type: ${vm}`);
117
- }
118
- });
95
+ async function getUEANonce(ctx, address) {
96
+ const chain = ctx.universalSigner.account.chain;
97
+ // A Push-native signer is an EOA, even when EIP-7702 delegation makes
98
+ // eth_getCode return a non-empty 0xef0100... designator. It uses the EVM
99
+ // transaction nonce and must never be queried through the UEA ABI.
100
+ if ((0, helpers_1.isPushChain)(chain)) {
101
+ return BigInt(0);
102
+ }
103
+ const { vm } = chain_1.CHAIN_INFO[chain];
104
+ switch (vm) {
105
+ case enums_1.VM.EVM:
106
+ return ctx.pushClient.readContract({
107
+ address,
108
+ abi: uea_evm_1.UEA_EVM,
109
+ functionName: 'nonce',
110
+ });
111
+ case enums_1.VM.SVM:
112
+ return ctx.pushClient.readContract({
113
+ address,
114
+ abi: uea_svm_1.UEA_SVM,
115
+ functionName: 'nonce',
116
+ });
117
+ default:
118
+ throw new Error(`Unsupported VM type: ${vm}`);
119
+ }
119
120
  }
120
- function getUeaNonceForExecution(ctx) {
121
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
122
- const UEA = computeUEAOffchain(ctx);
123
- const code = yield ctx.pushClient.publicClient.getCode({ address: UEA });
124
- return code !== undefined ? yield getUEANonce(ctx, UEA) : BigInt(0);
125
- });
121
+ async function getUeaNonceForExecution(ctx) {
122
+ if ((0, helpers_1.isPushChain)(ctx.universalSigner.account.chain)) {
123
+ return BigInt(0);
124
+ }
125
+ const UEA = computeUEAOffchain(ctx);
126
+ const code = await ctx.pushClient.publicClient.getCode({ address: UEA });
127
+ return code !== undefined ? await getUEANonce(ctx, UEA) : BigInt(0);
126
128
  }
127
- function getUeaStatusAndNonce(ctx) {
128
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
129
- const UEA = computeUEAOffchain(ctx);
130
- const code = yield ctx.pushClient.publicClient.getCode({ address: UEA });
131
- const deployed = code !== undefined;
132
- const nonce = deployed ? yield getUEANonce(ctx, UEA) : BigInt(0);
133
- return { deployed, nonce };
134
- });
129
+ async function getUeaStatusAndNonce(ctx) {
130
+ // Native Push accounts do not have a UEA. In particular, EIP-7702
131
+ // delegation code must not be mistaken for a deployed UEA proxy.
132
+ if ((0, helpers_1.isPushChain)(ctx.universalSigner.account.chain)) {
133
+ return { deployed: false, nonce: BigInt(0) };
134
+ }
135
+ const UEA = computeUEAOffchain(ctx);
136
+ const code = await ctx.pushClient.publicClient.getCode({ address: UEA });
137
+ const deployed = code !== undefined;
138
+ const nonce = deployed ? await getUEANonce(ctx, UEA) : BigInt(0);
139
+ return { deployed, nonce };
135
140
  }
136
141
  // ============================================================================
137
142
  // UEA Version
138
143
  // ============================================================================
139
- function fetchUEAVersion(ctx) {
140
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
141
- if (ctx.ueaVersionCache) {
142
- return ctx.ueaVersionCache;
143
- }
144
- const chain = ctx.universalSigner.account.chain;
145
- const { vm } = chain_1.CHAIN_INFO[chain];
146
- const abi = vm === enums_1.VM.EVM ? uea_evm_1.UEA_EVM : uea_svm_1.UEA_SVM;
147
- const predictedUEA = computeUEAOffchain(ctx);
148
- const code = yield ctx.pushClient.publicClient.getCode({
149
- address: predictedUEA,
150
- });
151
- if (code === undefined) {
152
- ctx.ueaVersionCache = '0.1.0';
153
- return '0.1.0';
154
- }
155
- const version = yield ctx.pushClient.readContract({
156
- address: predictedUEA,
157
- abi,
158
- functionName: 'VERSION',
159
- });
160
- ctx.ueaVersionCache = version;
161
- return version;
144
+ async function fetchUEAVersion(ctx) {
145
+ if (ctx.ueaVersionCache) {
146
+ return ctx.ueaVersionCache;
147
+ }
148
+ const chain = ctx.universalSigner.account.chain;
149
+ const { vm } = chain_1.CHAIN_INFO[chain];
150
+ const abi = vm === enums_1.VM.EVM ? uea_evm_1.UEA_EVM : uea_svm_1.UEA_SVM;
151
+ const predictedUEA = computeUEAOffchain(ctx);
152
+ const code = await ctx.pushClient.publicClient.getCode({
153
+ address: predictedUEA,
154
+ });
155
+ if (code === undefined) {
156
+ ctx.ueaVersionCache = '0.1.0';
157
+ return '0.1.0';
158
+ }
159
+ const version = await ctx.pushClient.readContract({
160
+ address: predictedUEA,
161
+ abi,
162
+ functionName: 'VERSION',
162
163
  });
164
+ ctx.ueaVersionCache = version;
165
+ return version;
163
166
  }
164
167
  //# sourceMappingURL=uea-manager.js.map
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = void 0;
4
4
  exports.quoteMaxPCForGasCap = quoteMaxPCForGasCap;
5
5
  exports.quoteMaxPCForGasCapFromNativeValue = quoteMaxPCForGasCapFromNativeValue;
6
- const BPS_DENOMINATOR = BigInt(10000);
7
- exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = 1000;
8
- exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = 10000;
6
+ const BPS_DENOMINATOR = BigInt(10_000);
7
+ exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS = 1_000;
8
+ exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = 10_000;
9
9
  /**
10
10
  * Builds a contract-safe maxPCForGas cap from a native PC gas-leg estimate.
11
11
  *
@@ -13,9 +13,8 @@ exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT = 10000;
13
13
  * returns the minimum matching nativeValueForGas as well as the cap.
14
14
  */
15
15
  function quoteMaxPCForGasCap(input) {
16
- var _a;
17
16
  assertNonNegativeBigInt('gasLegNativePc', input.gasLegNativePc);
18
- const protocolFee = (_a = input.protocolFee) !== null && _a !== void 0 ? _a : BigInt(0);
17
+ const protocolFee = input.protocolFee ?? BigInt(0);
19
18
  assertNonNegativeBigInt('protocolFee', protocolFee);
20
19
  const bufferBps = normalizeBufferBps(input.bufferBps);
21
20
  const maxPCForGas = applyBufferCeil(input.gasLegNativePc, bufferBps);
@@ -44,7 +43,7 @@ function quoteMaxPCForGasCapFromNativeValue(input) {
44
43
  });
45
44
  }
46
45
  function normalizeBufferBps(bufferBps) {
47
- const normalized = bufferBps !== null && bufferBps !== void 0 ? bufferBps : exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS;
46
+ const normalized = bufferBps ?? exports.DEFAULT_MAX_PC_FOR_GAS_BUFFER_BPS;
48
47
  if (!Number.isInteger(normalized) ||
49
48
  normalized < 0 ||
50
49
  normalized > exports.MAX_PC_FOR_GAS_BUFFER_BPS_LIMIT) {