@piprail/sdk 1.24.0 → 2.0.0
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.
- package/CHANGELOG.md +40 -0
- package/README.md +4 -4
- package/dist/{algorand-677ILBQS.js → algorand-RJ4DRWHV.js} +10 -18
- package/dist/{algorand-ZJ53VCTN.cjs → algorand-RUDF55XY.cjs} +23 -31
- package/dist/{aptos-XIIHPAOO.cjs → aptos-PESRG2EQ.cjs} +22 -30
- package/dist/{aptos-3TSKTI4D.js → aptos-SMEQXIYJ.js} +10 -18
- package/dist/{chunk-L6WQRHEZ.js → chunk-47VEOHZN.js} +13 -0
- package/dist/{chunk-U35MG4TF.cjs → chunk-DKQXW454.cjs} +14 -1
- package/dist/index.cjs +137 -105
- package/dist/index.d.cts +31 -32
- package/dist/index.d.ts +31 -32
- package/dist/index.js +56 -24
- package/dist/{near-TWA4PYOD.js → near-CHE7B2CY.js} +10 -18
- package/dist/{near-MG256A3E.cjs → near-VWBV3SUW.cjs} +24 -32
- package/dist/{solana-KWNRY5NR.js → solana-DTO2R3AT.js} +7 -10
- package/dist/{solana-UEMHFQH5.cjs → solana-OIHRPGX2.cjs} +33 -36
- package/dist/{stellar-SCRRPCEA.cjs → stellar-AF7PYMMF.cjs} +27 -37
- package/dist/{stellar-YB7JXKK4.js → stellar-T5VONOEO.js} +11 -21
- package/dist/{sui-LFT65OGU.cjs → sui-3TF5XVRT.cjs} +23 -31
- package/dist/{sui-IODKU2MA.js → sui-J53NYMVL.js} +10 -18
- package/dist/{ton-QN5GTOCS.js → ton-CPK57L2O.js} +9 -12
- package/dist/{ton-RAYJFKJC.cjs → ton-ZEI7YUK7.cjs} +20 -23
- package/dist/{tron-KX4VWS7V.cjs → tron-5B3Q4SMF.cjs} +30 -38
- package/dist/{tron-QSNCDYRB.js → tron-LZRCDRZC.js} +11 -19
- package/dist/{xrpl-ECHK3GIX.js → xrpl-AH4FFC2C.js} +11 -19
- package/dist/{xrpl-GXUFDXHU.cjs → xrpl-BL4QXOVN.cjs} +27 -35
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,44 @@ All notable changes to `@piprail/sdk` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
|
|
5
5
|
versions follow [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.0.0] — 2026-06-15 — one wallet field: `key` (BREAKING)
|
|
8
|
+
|
|
9
|
+
### Changed — the wallet secret is a single `key` field on every chain (BREAKING)
|
|
10
|
+
|
|
11
|
+
- **`WalletInput` is unified.** Every chain now takes `wallet: { key }` — the chain's secret as a
|
|
12
|
+
string. NEAR also keeps `accountId`: `{ accountId, key }`. The per-chain secret field names
|
|
13
|
+
(`privateKey` · `secretKey` · `seed` · `secret` · `mnemonic`) are **removed**.
|
|
14
|
+
- **Migration** — rename the field; the *value* is unchanged:
|
|
15
|
+
`{ privateKey } → { key }`, `{ secretKey } → { key }`, `{ seed } → { key }`,
|
|
16
|
+
`{ secret } → { key }`, `{ mnemonic } → { key }`, `{ accountId, privateKey } → { accountId, key }`.
|
|
17
|
+
Passing a pre-2.0 field name throws a `WrongFamilyError` whose message names the exact `{ key }` fix.
|
|
18
|
+
- **Bring-your-own native signer objects are unchanged** — EVM `{ walletClient }`, Solana `{ signer }`,
|
|
19
|
+
TON `{ keyPair }`, Stellar/Sui `{ keypair }`, XRPL `{ wallet }`, Aptos/Algorand `{ account }`.
|
|
20
|
+
- **Why** — one obvious shape across every chain, the whole point of "name a chain, add a wallet."
|
|
21
|
+
See [Wallets by family](https://docs.piprail.com/making-payments/wallets-by-family/).
|
|
22
|
+
|
|
23
|
+
Nothing else changed: the protocol, drivers, schemes, discovery, spend policy, and every other API
|
|
24
|
+
are identical. Live-verified across 11 mainnet chains with the new `{ key }` shape.
|
|
25
|
+
|
|
26
|
+
## [1.25.0] — 2026-06-15 — more keyless facilitators (live-verified)
|
|
27
|
+
|
|
28
|
+
### Added — `KNOWN_FACILITATORS` grows beyond PayAI
|
|
29
|
+
|
|
30
|
+
- **`KNOWN_FACILITATORS`** now seeds three more keyless facilitators, each **live-settled** on mainnet
|
|
31
|
+
through PipRail (a real `exact` payment, buyer paid zero gas), not just read from `/supported`:
|
|
32
|
+
**xpay** on Base (EIP-3009), and **OpenFacilitator** + **Corbits** on Solana (SVM). So
|
|
33
|
+
`firstKeylessFacilitator()` / the `exact: true` shorthand can resolve a keyless sponsor on more
|
|
34
|
+
networks, with redundancy beyond PayAI.
|
|
35
|
+
- **Daydreams** and **Questflow** are deliberately **not** seeded: their `/supported` is public but
|
|
36
|
+
`/verify` returns `401` (an API key is required), so they aren't keyless for *settlement*. A public
|
|
37
|
+
`/supported` is not proof of keyless settlement — every seeded entry carries a dated, live-verified note.
|
|
38
|
+
|
|
39
|
+
### Notes
|
|
40
|
+
|
|
41
|
+
- Pure data + comments; **no behaviour change** to existing rails or defaults. The full, current provider
|
|
42
|
+
matrix (incl. key-required and self-host options, with on-chain tx proofs) lives in the docs:
|
|
43
|
+
[Facilitator coverage](https://docs.piprail.com/accepting-payments/facilitator-coverage/).
|
|
44
|
+
|
|
7
45
|
## [1.24.0] — 2026-06-14 — multi-chain buying (one buyer, a wallet per chain)
|
|
8
46
|
|
|
9
47
|
### Added — pay a 402 on whichever chain it asks for
|
|
@@ -1064,6 +1102,8 @@ straight into your wallet. The API is small and self-contained.
|
|
|
1064
1102
|
to your wallet; PipRail never holds funds.
|
|
1065
1103
|
- `viem ^2.21` is a peer dependency. Node 20+ or a modern browser.
|
|
1066
1104
|
|
|
1105
|
+
[2.0.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
1106
|
+
[1.25.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
1067
1107
|
[1.24.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
1068
1108
|
[1.15.1]: https://www.npmjs.com/package/@piprail/sdk
|
|
1069
1109
|
[1.15.0]: https://www.npmjs.com/package/@piprail/sdk
|
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ That route now costs **0.05 USDC on Base**, paid straight to your wallet. One pa
|
|
|
31
31
|
```ts
|
|
32
32
|
import { PipRailClient } from '@piprail/sdk'
|
|
33
33
|
|
|
34
|
-
const client = new PipRailClient({ chain: 'base', wallet: {
|
|
34
|
+
const client = new PipRailClient({ chain: 'base', wallet: { key: process.env.AGENT_KEY } })
|
|
35
35
|
|
|
36
36
|
const res = await client.fetch('https://api.example.com/report') // hits the 402, pays it, retries with proof
|
|
37
37
|
```
|
|
@@ -49,9 +49,9 @@ import { MultiChainPayer } from '@piprail/sdk'
|
|
|
49
49
|
|
|
50
50
|
const payer = MultiChainPayer.fromWallets({
|
|
51
51
|
wallets: {
|
|
52
|
-
base: {
|
|
53
|
-
solana: {
|
|
54
|
-
xrpl: {
|
|
52
|
+
base: { key: process.env.EVM_KEY }, // one EVM key works on every EVM chain
|
|
53
|
+
solana: { key: process.env.SOLANA_KEY },
|
|
54
|
+
xrpl: { key: process.env.XRPL_SEED },
|
|
55
55
|
},
|
|
56
56
|
policy: { maxAmount: '1.00', maxTotal: '10.00', tokens: ['USDC', 'USDT'] }, // one budget, every chain
|
|
57
57
|
})
|
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
RecipientNotReadyError,
|
|
5
5
|
UnknownTokenError,
|
|
6
6
|
WrongFamilyError,
|
|
7
|
+
assertNoLegacyWalletKey,
|
|
7
8
|
nativeCost,
|
|
8
9
|
rejectForeignToken,
|
|
9
10
|
toInsufficientFundsError
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-47VEOHZN.js";
|
|
11
12
|
|
|
12
13
|
// src/drivers/algorand/index.ts
|
|
13
14
|
import algosdk2 from "algosdk";
|
|
@@ -158,22 +159,13 @@ import algosdk from "algosdk";
|
|
|
158
159
|
function assertAlgorandWallet(wallet, network) {
|
|
159
160
|
if (typeof wallet !== "object" || wallet === null) {
|
|
160
161
|
throw new WrongFamilyError(
|
|
161
|
-
`chain ${network} is Algorand; wallet must be {
|
|
162
|
+
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
162
163
|
);
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
assertNoLegacyWalletKey(wallet, "Algorand");
|
|
166
|
+
if (!("key" in wallet) && !("account" in wallet)) {
|
|
165
167
|
throw new WrongFamilyError(
|
|
166
|
-
`chain ${network} is Algorand;
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
if ("secretKey" in wallet || "signer" in wallet || "secret" in wallet || "keypair" in wallet || "keyPair" in wallet || "seed" in wallet || "accountId" in wallet) {
|
|
170
|
-
throw new WrongFamilyError(
|
|
171
|
-
`chain ${network} is Algorand; that looks like another family's wallet \u2014 pass { mnemonic } (25 words) or { account }.`
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
if (!("mnemonic" in wallet) && !("account" in wallet)) {
|
|
175
|
-
throw new WrongFamilyError(
|
|
176
|
-
`chain ${network} is Algorand; wallet must be { mnemonic } (25 words) or { account }.`
|
|
168
|
+
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
177
169
|
);
|
|
178
170
|
}
|
|
179
171
|
return wallet;
|
|
@@ -182,18 +174,18 @@ function resolveAlgorandWallet(config) {
|
|
|
182
174
|
if (config.account) {
|
|
183
175
|
return { addr: String(config.account.addr), sk: config.account.sk };
|
|
184
176
|
}
|
|
185
|
-
if (config.
|
|
177
|
+
if (config.key != null) {
|
|
186
178
|
try {
|
|
187
|
-
const { addr, sk } = algosdk.mnemonicToSecretKey(config.
|
|
179
|
+
const { addr, sk } = algosdk.mnemonicToSecretKey(config.key);
|
|
188
180
|
return { addr: addr.toString(), sk };
|
|
189
181
|
} catch (cause) {
|
|
190
182
|
throw new WrongFamilyError(
|
|
191
|
-
"Algorand wallet {
|
|
183
|
+
"Algorand wallet { key } is not a valid 25-word Algorand mnemonic.",
|
|
192
184
|
{ cause }
|
|
193
185
|
);
|
|
194
186
|
}
|
|
195
187
|
}
|
|
196
|
-
throw new WrongFamilyError("Algorand wallet needs {
|
|
188
|
+
throw new WrongFamilyError("Algorand wallet needs { key } (25-word mnemonic) or { account }.");
|
|
197
189
|
}
|
|
198
190
|
|
|
199
191
|
// src/drivers/algorand/index.ts
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
11
12
|
|
|
12
13
|
// src/drivers/algorand/index.ts
|
|
13
14
|
var _algosdk = require('algosdk'); var _algosdk2 = _interopRequireDefault(_algosdk);
|
|
@@ -55,13 +56,13 @@ async function payAlgorand(params) {
|
|
|
55
56
|
} catch (err) {
|
|
56
57
|
const mapped = mapAlgorandError(err, accept.payTo);
|
|
57
58
|
if (mapped) throw mapped;
|
|
58
|
-
throw _nullishCoalesce(
|
|
59
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
function mapAlgorandError(err, payTo) {
|
|
62
63
|
const m = err instanceof Error ? err.message : String(err);
|
|
63
64
|
if (/must optin/i.test(m) || /missing from/i.test(m) && m.includes(payTo)) {
|
|
64
|
-
return new (0,
|
|
65
|
+
return new (0, _chunkDKQXW454cjs.RecipientNotReadyError)(
|
|
65
66
|
`Algorand recipient ${payTo} hasn't opted into this asset \u2014 it must opt in (a 0-amount asset transfer to itself) before it can receive. (Algorand: ${firstLine(m)})`,
|
|
66
67
|
{ cause: err }
|
|
67
68
|
);
|
|
@@ -69,7 +70,7 @@ function mapAlgorandError(err, payTo) {
|
|
|
69
70
|
if (/overspend|below min|min(imum)? balance|tried to spend|balance \d+ below|asset \d+ missing from|insufficient|underflow/i.test(
|
|
70
71
|
m
|
|
71
72
|
)) {
|
|
72
|
-
return new (0,
|
|
73
|
+
return new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
73
74
|
`Algorand payment failed: the sender can't cover it \u2014 token balance, ALGO for fees, the 0.1-ALGO minimum balance, or a missing asset opt-in on the sender. (Algorand: ${firstLine(m)})`,
|
|
74
75
|
{ cause: err }
|
|
75
76
|
);
|
|
@@ -157,23 +158,14 @@ function rpcFailed(nonce) {
|
|
|
157
158
|
|
|
158
159
|
function assertAlgorandWallet(wallet, network) {
|
|
159
160
|
if (typeof wallet !== "object" || wallet === null) {
|
|
160
|
-
throw new (0,
|
|
161
|
-
`chain ${network} is Algorand; wallet must be {
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
165
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
166
|
-
`chain ${network} is Algorand; an EVM/Aptos wallet can't be used \u2014 pass { mnemonic } (25 words) or { account }.`
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
if ("secretKey" in wallet || "signer" in wallet || "secret" in wallet || "keypair" in wallet || "keyPair" in wallet || "seed" in wallet || "accountId" in wallet) {
|
|
170
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
171
|
-
`chain ${network} is Algorand; that looks like another family's wallet \u2014 pass { mnemonic } (25 words) or { account }.`
|
|
161
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
162
|
+
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
172
163
|
);
|
|
173
164
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
165
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Algorand");
|
|
166
|
+
if (!("key" in wallet) && !("account" in wallet)) {
|
|
167
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
168
|
+
`chain ${network} is Algorand; wallet must be { key } (25-word mnemonic) or { account }.`
|
|
177
169
|
);
|
|
178
170
|
}
|
|
179
171
|
return wallet;
|
|
@@ -182,18 +174,18 @@ function resolveAlgorandWallet(config) {
|
|
|
182
174
|
if (config.account) {
|
|
183
175
|
return { addr: String(config.account.addr), sk: config.account.sk };
|
|
184
176
|
}
|
|
185
|
-
if (config.
|
|
177
|
+
if (config.key != null) {
|
|
186
178
|
try {
|
|
187
|
-
const { addr, sk } = _algosdk2.default.mnemonicToSecretKey(config.
|
|
179
|
+
const { addr, sk } = _algosdk2.default.mnemonicToSecretKey(config.key);
|
|
188
180
|
return { addr: addr.toString(), sk };
|
|
189
181
|
} catch (cause) {
|
|
190
|
-
throw new (0,
|
|
191
|
-
"Algorand wallet {
|
|
182
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
183
|
+
"Algorand wallet { key } is not a valid 25-word Algorand mnemonic.",
|
|
192
184
|
{ cause }
|
|
193
185
|
);
|
|
194
186
|
}
|
|
195
187
|
}
|
|
196
|
-
throw new (0,
|
|
188
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("Algorand wallet needs { key } (25-word mnemonic) or { account }.");
|
|
197
189
|
}
|
|
198
190
|
|
|
199
191
|
// src/drivers/algorand/index.ts
|
|
@@ -248,16 +240,16 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
248
240
|
const info = preset.tokens[token.toUpperCase()];
|
|
249
241
|
if (!info) {
|
|
250
242
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
251
|
-
throw new (0,
|
|
243
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
252
244
|
`token "${token}" isn't built in for Algorand (known: ${known}). Pass { assetId, decimals } for a custom ASA, or use 'native'.`
|
|
253
245
|
);
|
|
254
246
|
}
|
|
255
247
|
return { asset: algorandAssetId(info.assetId), decimals: info.decimals, symbol: info.symbol };
|
|
256
248
|
}
|
|
257
|
-
|
|
249
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "algorand", network);
|
|
258
250
|
const t = token;
|
|
259
251
|
if (typeof t.assetId !== "number" || typeof t.decimals !== "number") {
|
|
260
|
-
throw new (0,
|
|
252
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
261
253
|
`chain ${network} is Algorand; a custom token must be { assetId, decimals }.`
|
|
262
254
|
);
|
|
263
255
|
}
|
|
@@ -278,12 +270,12 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
278
270
|
},
|
|
279
271
|
assertValidPayTo(payTo) {
|
|
280
272
|
if (payTo.startsWith("0x")) {
|
|
281
|
-
throw new (0,
|
|
273
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
282
274
|
`chain ${network} is Algorand, but payTo "${payTo}" looks like an EVM address.`
|
|
283
275
|
);
|
|
284
276
|
}
|
|
285
277
|
if (!_algosdk2.default.isValidAddress(payTo)) {
|
|
286
|
-
throw new (0,
|
|
278
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
287
279
|
`chain ${network} is Algorand, but payTo "${payTo}" is not a valid Algorand address.`
|
|
288
280
|
);
|
|
289
281
|
}
|
|
@@ -300,13 +292,13 @@ function makeAlgorandNetwork(preset, algodUrl) {
|
|
|
300
292
|
const info = await _algosdk2.default.waitForConfirmation(algod, ref, 10);
|
|
301
293
|
return { height: String(_nullishCoalesce(info.confirmedRound, () => ( 0))) };
|
|
302
294
|
} catch (err) {
|
|
303
|
-
throw new (0,
|
|
295
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(`Algorand tx ${ref} did not confirm in time.`, {
|
|
304
296
|
cause: err
|
|
305
297
|
});
|
|
306
298
|
}
|
|
307
299
|
},
|
|
308
300
|
async estimateCost() {
|
|
309
|
-
return
|
|
301
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
310
302
|
symbol: ALGO_SYMBOL,
|
|
311
303
|
decimals: ALGO_DECIMALS,
|
|
312
304
|
fee: 1000n,
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
var _chunkDKQXW454cjs = require('./chunk-DKQXW454.cjs');
|
|
10
11
|
|
|
11
12
|
// src/drivers/aptos/index.ts
|
|
12
13
|
var _tssdk = require('@aptos-labs/ts-sdk');
|
|
@@ -55,14 +56,14 @@ async function payAptos(params) {
|
|
|
55
56
|
const res = await client.signSubmit({ signer, transaction });
|
|
56
57
|
return res.hash;
|
|
57
58
|
} catch (err) {
|
|
58
|
-
if (err instanceof
|
|
59
|
+
if (err instanceof _chunkDKQXW454cjs.InsufficientFundsError) throw err;
|
|
59
60
|
if (isAptosAffordability(err)) {
|
|
60
|
-
throw new (0,
|
|
61
|
+
throw new (0, _chunkDKQXW454cjs.InsufficientFundsError)(
|
|
61
62
|
err instanceof Error ? err.message : "Insufficient APT/token balance for the payment.",
|
|
62
63
|
{ cause: err }
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
|
-
throw _nullishCoalesce(
|
|
66
|
+
throw _nullishCoalesce(_chunkDKQXW454cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
function isAptosAffordability(err) {
|
|
@@ -146,40 +147,31 @@ function txNotFound(hash) {
|
|
|
146
147
|
|
|
147
148
|
function assertAptosWallet(wallet, network) {
|
|
148
149
|
if (typeof wallet !== "object" || wallet === null) {
|
|
149
|
-
throw new (0,
|
|
150
|
-
`chain ${network} is Aptos; wallet must be {
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
if ("walletClient" in wallet) {
|
|
154
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
155
|
-
`chain ${network} is Aptos; a viem { walletClient } can't be used \u2014 pass { privateKey } (ed25519-priv-0x\u2026) or { account }.`
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keypair" in wallet || "keyPair" in wallet || "secret" in wallet || "seed" in wallet || "accountId" in wallet) {
|
|
159
|
-
throw new (0, _chunkU35MG4TFcjs.WrongFamilyError)(
|
|
160
|
-
`chain ${network} is Aptos; that looks like another family's wallet \u2014 pass { privateKey } (ed25519-priv-0x\u2026) or { account }.`
|
|
150
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
151
|
+
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
161
152
|
);
|
|
162
153
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
_chunkDKQXW454cjs.assertNoLegacyWalletKey.call(void 0, wallet, "Aptos");
|
|
155
|
+
if (!("key" in wallet) && !("account" in wallet)) {
|
|
156
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
157
|
+
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
166
158
|
);
|
|
167
159
|
}
|
|
168
160
|
return wallet;
|
|
169
161
|
}
|
|
170
162
|
function resolveAptosAccount(config) {
|
|
171
163
|
if (config.account) return config.account;
|
|
172
|
-
if (config.
|
|
164
|
+
if (config.key != null) {
|
|
173
165
|
try {
|
|
174
|
-
return _tssdk.Account.fromPrivateKey({ privateKey: new (0, _tssdk.Ed25519PrivateKey)(config.
|
|
166
|
+
return _tssdk.Account.fromPrivateKey({ privateKey: new (0, _tssdk.Ed25519PrivateKey)(config.key) });
|
|
175
167
|
} catch (cause) {
|
|
176
|
-
throw new (0,
|
|
177
|
-
"Aptos wallet {
|
|
168
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
169
|
+
"Aptos wallet { key } is not a valid ed25519 secret (ed25519-priv-0x\u2026 or 0x\u2026 hex).",
|
|
178
170
|
{ cause }
|
|
179
171
|
);
|
|
180
172
|
}
|
|
181
173
|
}
|
|
182
|
-
throw new (0,
|
|
174
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)("Aptos wallet needs { key } (ed25519-priv-0x\u2026) or { account }.");
|
|
183
175
|
}
|
|
184
176
|
|
|
185
177
|
// src/drivers/aptos/index.ts
|
|
@@ -251,16 +243,16 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
251
243
|
const info = preset.tokens[token.toUpperCase()];
|
|
252
244
|
if (!info) {
|
|
253
245
|
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
254
|
-
throw new (0,
|
|
246
|
+
throw new (0, _chunkDKQXW454cjs.UnknownTokenError)(
|
|
255
247
|
`token "${token}" isn't built in for Aptos (known: ${known}). Pass { metadata, decimals } for a custom Fungible Asset, or use 'native'.`
|
|
256
248
|
);
|
|
257
249
|
}
|
|
258
250
|
return { asset: info.metadata, decimals: info.decimals, symbol: info.symbol };
|
|
259
251
|
}
|
|
260
|
-
|
|
252
|
+
_chunkDKQXW454cjs.rejectForeignToken.call(void 0, token, "aptos", network);
|
|
261
253
|
const t = token;
|
|
262
254
|
if (!t.metadata || typeof t.decimals !== "number") {
|
|
263
|
-
throw new (0,
|
|
255
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
264
256
|
`chain ${network} is Aptos; a custom token must be { metadata, decimals }.`
|
|
265
257
|
);
|
|
266
258
|
}
|
|
@@ -287,7 +279,7 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
287
279
|
valid = false;
|
|
288
280
|
}
|
|
289
281
|
if (!valid || evmLike) {
|
|
290
|
-
throw new (0,
|
|
282
|
+
throw new (0, _chunkDKQXW454cjs.WrongFamilyError)(
|
|
291
283
|
`chain ${network} is Aptos, but payTo "${payTo}" is not a valid Aptos address (0x + 32 bytes).`
|
|
292
284
|
);
|
|
293
285
|
}
|
|
@@ -309,11 +301,11 @@ function makeAptosNetwork(preset, rpcUrl) {
|
|
|
309
301
|
const tx = await aptos.waitForTransaction({ transactionHash: ref });
|
|
310
302
|
return { height: String(_nullishCoalesce(tx.version, () => ( "0"))) };
|
|
311
303
|
} catch (err) {
|
|
312
|
-
throw new (0,
|
|
304
|
+
throw new (0, _chunkDKQXW454cjs.ConfirmationTimeoutError)(`Aptos tx ${ref} did not finalize in time.`, { cause: err });
|
|
313
305
|
}
|
|
314
306
|
},
|
|
315
307
|
async estimateCost() {
|
|
316
|
-
return
|
|
308
|
+
return _chunkDKQXW454cjs.nativeCost.call(void 0, {
|
|
317
309
|
symbol: APT_SYMBOL,
|
|
318
310
|
decimals: APT_DECIMALS,
|
|
319
311
|
fee: 100000n,
|
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
InsufficientFundsError,
|
|
4
4
|
UnknownTokenError,
|
|
5
5
|
WrongFamilyError,
|
|
6
|
+
assertNoLegacyWalletKey,
|
|
6
7
|
nativeCost,
|
|
7
8
|
rejectForeignToken,
|
|
8
9
|
toInsufficientFundsError
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-47VEOHZN.js";
|
|
10
11
|
|
|
11
12
|
// src/drivers/aptos/index.ts
|
|
12
13
|
import { Aptos, AptosConfig, Network, AccountAddress } from "@aptos-labs/ts-sdk";
|
|
@@ -147,39 +148,30 @@ import { Account, Ed25519PrivateKey } from "@aptos-labs/ts-sdk";
|
|
|
147
148
|
function assertAptosWallet(wallet, network) {
|
|
148
149
|
if (typeof wallet !== "object" || wallet === null) {
|
|
149
150
|
throw new WrongFamilyError(
|
|
150
|
-
`chain ${network} is Aptos; wallet must be {
|
|
151
|
+
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
151
152
|
);
|
|
152
153
|
}
|
|
153
|
-
|
|
154
|
+
assertNoLegacyWalletKey(wallet, "Aptos");
|
|
155
|
+
if (!("key" in wallet) && !("account" in wallet)) {
|
|
154
156
|
throw new WrongFamilyError(
|
|
155
|
-
`chain ${network} is Aptos;
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
if ("secretKey" in wallet || "signer" in wallet || "mnemonic" in wallet || "keypair" in wallet || "keyPair" in wallet || "secret" in wallet || "seed" in wallet || "accountId" in wallet) {
|
|
159
|
-
throw new WrongFamilyError(
|
|
160
|
-
`chain ${network} is Aptos; that looks like another family's wallet \u2014 pass { privateKey } (ed25519-priv-0x\u2026) or { account }.`
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
if (!("privateKey" in wallet) && !("account" in wallet)) {
|
|
164
|
-
throw new WrongFamilyError(
|
|
165
|
-
`chain ${network} is Aptos; wallet must be { privateKey } (ed25519-priv-0x\u2026) or { account }.`
|
|
157
|
+
`chain ${network} is Aptos; wallet must be { key } (ed25519-priv-0x\u2026) or { account }.`
|
|
166
158
|
);
|
|
167
159
|
}
|
|
168
160
|
return wallet;
|
|
169
161
|
}
|
|
170
162
|
function resolveAptosAccount(config) {
|
|
171
163
|
if (config.account) return config.account;
|
|
172
|
-
if (config.
|
|
164
|
+
if (config.key != null) {
|
|
173
165
|
try {
|
|
174
|
-
return Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey(config.
|
|
166
|
+
return Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey(config.key) });
|
|
175
167
|
} catch (cause) {
|
|
176
168
|
throw new WrongFamilyError(
|
|
177
|
-
"Aptos wallet {
|
|
169
|
+
"Aptos wallet { key } is not a valid ed25519 secret (ed25519-priv-0x\u2026 or 0x\u2026 hex).",
|
|
178
170
|
{ cause }
|
|
179
171
|
);
|
|
180
172
|
}
|
|
181
173
|
}
|
|
182
|
-
throw new WrongFamilyError("Aptos wallet needs {
|
|
174
|
+
throw new WrongFamilyError("Aptos wallet needs { key } (ed25519-priv-0x\u2026) or { account }.");
|
|
183
175
|
}
|
|
184
176
|
|
|
185
177
|
// src/drivers/aptos/index.ts
|
|
@@ -174,6 +174,18 @@ function nativeCost(opts) {
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
// src/drivers/wallet-migrate.ts
|
|
178
|
+
var LEGACY_WALLET_FIELDS = ["privateKey", "secretKey", "seed", "secret", "mnemonic"];
|
|
179
|
+
function assertNoLegacyWalletKey(wallet, family) {
|
|
180
|
+
for (const f of LEGACY_WALLET_FIELDS) {
|
|
181
|
+
if (f in wallet) {
|
|
182
|
+
throw new WrongFamilyError(
|
|
183
|
+
`${family} wallet: PipRail v2 unified the wallet secret to a single field \u2014 replace { ${f} } with { key }` + (family === "NEAR" ? " ({ accountId, key })" : "") + "."
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
177
189
|
export {
|
|
178
190
|
PipRailError,
|
|
179
191
|
InsufficientFundsError,
|
|
@@ -194,6 +206,7 @@ export {
|
|
|
194
206
|
UnknownTokenError,
|
|
195
207
|
MissingDriverError,
|
|
196
208
|
UnsupportedNetworkError,
|
|
209
|
+
assertNoLegacyWalletKey,
|
|
197
210
|
rejectForeignToken,
|
|
198
211
|
parseUnits,
|
|
199
212
|
floorUnits,
|
|
@@ -174,6 +174,19 @@ function nativeCost(opts) {
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
// src/drivers/wallet-migrate.ts
|
|
178
|
+
var LEGACY_WALLET_FIELDS = ["privateKey", "secretKey", "seed", "secret", "mnemonic"];
|
|
179
|
+
function assertNoLegacyWalletKey(wallet, family) {
|
|
180
|
+
for (const f of LEGACY_WALLET_FIELDS) {
|
|
181
|
+
if (f in wallet) {
|
|
182
|
+
throw new WrongFamilyError(
|
|
183
|
+
`${family} wallet: PipRail v2 unified the wallet secret to a single field \u2014 replace { ${f} } with { key }` + (family === "NEAR" ? " ({ accountId, key })" : "") + "."
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
177
190
|
|
|
178
191
|
|
|
179
192
|
|
|
@@ -199,4 +212,4 @@ function nativeCost(opts) {
|
|
|
199
212
|
|
|
200
213
|
|
|
201
214
|
|
|
202
|
-
exports.PipRailError = PipRailError; exports.InsufficientFundsError = InsufficientFundsError; exports.RecipientNotReadyError = RecipientNotReadyError; exports.toInsufficientFundsError = toInsufficientFundsError; exports.WrongChainError = WrongChainError; exports.PaymentTimeoutError = PaymentTimeoutError; exports.MaxRetriesExceededError = MaxRetriesExceededError; exports.PaymentDeclinedError = PaymentDeclinedError; exports.ConfirmationTimeoutError = ConfirmationTimeoutError; exports.SettlementError = SettlementError; exports.InvalidEnvelopeError = InvalidEnvelopeError; exports.NoCompatibleAcceptError = NoCompatibleAcceptError; exports.UnsupportedSchemeError = UnsupportedSchemeError; exports.NonReplayableBodyError = NonReplayableBodyError; exports.WalletRequiredError = WalletRequiredError; exports.WrongFamilyError = WrongFamilyError; exports.UnknownTokenError = UnknownTokenError; exports.MissingDriverError = MissingDriverError; exports.UnsupportedNetworkError = UnsupportedNetworkError; exports.rejectForeignToken = rejectForeignToken; exports.parseUnits = parseUnits; exports.floorUnits = floorUnits; exports.formatUnits = formatUnits; exports.nativeCost = nativeCost;
|
|
215
|
+
exports.PipRailError = PipRailError; exports.InsufficientFundsError = InsufficientFundsError; exports.RecipientNotReadyError = RecipientNotReadyError; exports.toInsufficientFundsError = toInsufficientFundsError; exports.WrongChainError = WrongChainError; exports.PaymentTimeoutError = PaymentTimeoutError; exports.MaxRetriesExceededError = MaxRetriesExceededError; exports.PaymentDeclinedError = PaymentDeclinedError; exports.ConfirmationTimeoutError = ConfirmationTimeoutError; exports.SettlementError = SettlementError; exports.InvalidEnvelopeError = InvalidEnvelopeError; exports.NoCompatibleAcceptError = NoCompatibleAcceptError; exports.UnsupportedSchemeError = UnsupportedSchemeError; exports.NonReplayableBodyError = NonReplayableBodyError; exports.WalletRequiredError = WalletRequiredError; exports.WrongFamilyError = WrongFamilyError; exports.UnknownTokenError = UnknownTokenError; exports.MissingDriverError = MissingDriverError; exports.UnsupportedNetworkError = UnsupportedNetworkError; exports.assertNoLegacyWalletKey = assertNoLegacyWalletKey; exports.rejectForeignToken = rejectForeignToken; exports.parseUnits = parseUnits; exports.floorUnits = floorUnits; exports.formatUnits = formatUnits; exports.nativeCost = nativeCost;
|