@piprail/sdk 1.3.1 → 1.5.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/CHAINS.md +31 -7
- package/CHANGELOG.md +74 -0
- package/ERRORS.md +13 -2
- package/README.md +46 -12
- package/dist/algorand-B67G4335.js +397 -0
- package/dist/algorand-IJJKE35X.cjs +397 -0
- package/dist/{aptos-MKZ5MAGL.cjs → aptos-X3G2UBYW.cjs} +44 -16
- package/dist/{aptos-DTAONNMM.js → aptos-YQWTGFRZ.js} +29 -1
- package/dist/{chunk-YJPWIK5L.cjs → chunk-IQGT65WS.cjs} +4 -2
- package/dist/{chunk-AGKC3C7Y.js → chunk-QDS6FBZP.js} +4 -2
- package/dist/index.cjs +358 -67
- package/dist/index.d.cts +162 -4
- package/dist/index.d.ts +162 -4
- package/dist/index.js +308 -17
- package/dist/{near-YX3XOASO.js → near-7MBBCDUE.js} +51 -1
- package/dist/{near-DISWUB7Y.cjs → near-GGUHLXAF.cjs} +76 -26
- package/dist/{solana-37F2PR5H.js → solana-7WJVZGDW.js} +23 -1
- package/dist/{solana-RJPNEFSN.cjs → solana-W24TCJV4.cjs} +39 -17
- package/dist/{stellar-ALOVOMFD.js → stellar-HV6VGZX3.js} +51 -1
- package/dist/{stellar-SUGNX52Z.cjs → stellar-YMY3K2YB.cjs} +70 -20
- package/dist/{sui-OLC5ID4X.js → sui-2WFWVFJX.js} +24 -1
- package/dist/{sui-HZWPHVU4.cjs → sui-32KVESR5.cjs} +40 -17
- package/dist/{ton-NIDWF77T.js → ton-DGZB7W4U.js} +24 -1
- package/dist/{ton-C4KTFXDL.cjs → ton-FIQGV2LC.cjs} +37 -14
- package/dist/{tron-LPMK57H7.js → tron-RLIL2FDI.js} +29 -1
- package/dist/{tron-DTU7NPEM.cjs → tron-ZSXAPZ2C.cjs} +52 -24
- package/dist/{xrpl-N6ZAJRGC.cjs → xrpl-2PKP7HOI.cjs} +81 -21
- package/dist/{xrpl-6ODQS7JR.js → xrpl-UEC2GYVV.js} +61 -1
- package/package.json +9 -2
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfirmationTimeoutError,
|
|
3
|
+
InsufficientFundsError,
|
|
4
|
+
RecipientNotReadyError,
|
|
5
|
+
UnknownTokenError,
|
|
6
|
+
WrongFamilyError,
|
|
7
|
+
nativeCost,
|
|
8
|
+
rejectForeignToken,
|
|
9
|
+
toInsufficientFundsError
|
|
10
|
+
} from "./chunk-QDS6FBZP.js";
|
|
11
|
+
|
|
12
|
+
// src/drivers/algorand/index.ts
|
|
13
|
+
import algosdk2 from "algosdk";
|
|
14
|
+
|
|
15
|
+
// src/drivers/algorand/chains.ts
|
|
16
|
+
var ALGO_DECIMALS = 6;
|
|
17
|
+
var ALGO_SYMBOL = "ALGO";
|
|
18
|
+
var ALGORAND_MAINNET = {
|
|
19
|
+
caip2: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k",
|
|
20
|
+
defaultAlgod: "https://mainnet-api.algonode.cloud",
|
|
21
|
+
defaultIndexer: "https://mainnet-idx.algonode.cloud",
|
|
22
|
+
tokens: {
|
|
23
|
+
// Circle USDC — ASA id + 6 decimals verified live on mainnet algod
|
|
24
|
+
// (/v2/assets/31566704 → unit-name "USDC", decimals 6, creator = Circle) before shipping.
|
|
25
|
+
// USDC-only: Tether deprecated USDT on Algorand, so it's intentionally omitted.
|
|
26
|
+
USDC: { assetId: 31566704, decimals: 6, symbol: "USDC" }
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function algorandAssetId(assetId) {
|
|
30
|
+
return String(assetId);
|
|
31
|
+
}
|
|
32
|
+
function parseAlgorandAssetId(asset) {
|
|
33
|
+
if (asset === "native") return null;
|
|
34
|
+
if (!/^\d+$/.test(asset)) return null;
|
|
35
|
+
const n = Number(asset);
|
|
36
|
+
return Number.isSafeInteger(n) && n > 0 ? n : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/drivers/algorand/pay.ts
|
|
40
|
+
async function payAlgorand(params) {
|
|
41
|
+
const { client, sk, sender, accept } = params;
|
|
42
|
+
const note = new TextEncoder().encode(accept.extra.nonce);
|
|
43
|
+
const amount = BigInt(accept.amount);
|
|
44
|
+
const assetId = parseAlgorandAssetId(accept.asset);
|
|
45
|
+
try {
|
|
46
|
+
const { txn, txId } = await client.build({
|
|
47
|
+
sender,
|
|
48
|
+
receiver: accept.payTo,
|
|
49
|
+
amount,
|
|
50
|
+
note,
|
|
51
|
+
...assetId === null ? {} : { assetId }
|
|
52
|
+
});
|
|
53
|
+
await client.signSend({ txn, sk });
|
|
54
|
+
return txId;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
const mapped = mapAlgorandError(err, accept.payTo);
|
|
57
|
+
if (mapped) throw mapped;
|
|
58
|
+
throw toInsufficientFundsError(err) ?? err;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function mapAlgorandError(err, payTo) {
|
|
62
|
+
const m = err instanceof Error ? err.message : String(err);
|
|
63
|
+
if (/must optin/i.test(m) || /missing from/i.test(m) && m.includes(payTo)) {
|
|
64
|
+
return new RecipientNotReadyError(
|
|
65
|
+
`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
|
+
{ cause: err }
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (/overspend|below min|min(imum)? balance|tried to spend|balance \d+ below|asset \d+ missing from|insufficient|underflow/i.test(
|
|
70
|
+
m
|
|
71
|
+
)) {
|
|
72
|
+
return new InsufficientFundsError(
|
|
73
|
+
`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
|
+
{ cause: err }
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function firstLine(message) {
|
|
80
|
+
return message.split("\n")[0].slice(0, 160);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/drivers/algorand/verify.ts
|
|
84
|
+
async function verifyAlgorand(params) {
|
|
85
|
+
const { reader, accept } = params;
|
|
86
|
+
const nonce = accept.extra.nonce;
|
|
87
|
+
const required = BigInt(accept.amount);
|
|
88
|
+
const wantAssetId = parseAlgorandAssetId(accept.asset);
|
|
89
|
+
let txs;
|
|
90
|
+
try {
|
|
91
|
+
txs = await reader.transactionsForAccount(accept.payTo, 50);
|
|
92
|
+
} catch {
|
|
93
|
+
return rpcFailed(nonce);
|
|
94
|
+
}
|
|
95
|
+
const tx = txs.find((t) => typeof t.note === "string" && t.note === nonce);
|
|
96
|
+
if (!tx) return notFound(nonce);
|
|
97
|
+
if (typeof tx.roundTime === "number") {
|
|
98
|
+
const ageSeconds = Math.floor(Date.now() / 1e3) - tx.roundTime;
|
|
99
|
+
if (Number.isFinite(ageSeconds) && ageSeconds > accept.maxTimeoutSeconds) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
error: "payment_expired",
|
|
103
|
+
detail: `Payment is ${ageSeconds}s old; max allowed is ${accept.maxTimeoutSeconds}s.`
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const isNative = wantAssetId === null;
|
|
108
|
+
const typeOk = isNative ? tx.txType === "pay" : tx.txType === "axfer";
|
|
109
|
+
const assetOk = isNative ? tx.assetId == null : tx.assetId === wantAssetId;
|
|
110
|
+
if (!typeOk || tx.receiver !== accept.payTo || !assetOk) {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
error: "transfer_not_found",
|
|
114
|
+
detail: `Algorand tx ${tx.id} carries our nonce but has no matching ${isNative ? "ALGO" : `ASA ${wantAssetId}`} transfer to ${accept.payTo}.`
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
let paid = 0n;
|
|
118
|
+
try {
|
|
119
|
+
paid = tx.amount ? BigInt(tx.amount) : 0n;
|
|
120
|
+
} catch {
|
|
121
|
+
paid = 0n;
|
|
122
|
+
}
|
|
123
|
+
if (paid < required) {
|
|
124
|
+
return { ok: false, error: "amount_too_low", detail: `Paid ${paid}, required ${required}.` };
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
receipt: {
|
|
129
|
+
scheme: "onchain-proof",
|
|
130
|
+
success: true,
|
|
131
|
+
network: accept.network,
|
|
132
|
+
transaction: tx.id,
|
|
133
|
+
asset: accept.asset,
|
|
134
|
+
amount: accept.amount,
|
|
135
|
+
payer: tx.sender ?? "",
|
|
136
|
+
payTo: accept.payTo,
|
|
137
|
+
verifiedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function notFound(nonce) {
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
error: "transfer_not_found",
|
|
145
|
+
detail: `No matching Algorand payment found for nonce ${nonce} (not yet settled, or wrong recipient/amount/asset/note).`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function rpcFailed(nonce) {
|
|
149
|
+
return {
|
|
150
|
+
ok: false,
|
|
151
|
+
error: "tx_not_found",
|
|
152
|
+
detail: `Could not read the Algorand indexer for nonce ${nonce} (transient RPC failure) \u2014 retry.`
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/drivers/algorand/wallet.ts
|
|
157
|
+
import algosdk from "algosdk";
|
|
158
|
+
function assertAlgorandWallet(wallet, network) {
|
|
159
|
+
if (typeof wallet !== "object" || wallet === null) {
|
|
160
|
+
throw new WrongFamilyError(
|
|
161
|
+
`chain ${network} is Algorand; wallet must be { mnemonic } (25 words) or { account }.`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
if ("privateKey" in wallet || "walletClient" in wallet) {
|
|
165
|
+
throw new 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 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 }.`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return wallet;
|
|
180
|
+
}
|
|
181
|
+
function resolveAlgorandWallet(config) {
|
|
182
|
+
if (config.account) {
|
|
183
|
+
return { addr: String(config.account.addr), sk: config.account.sk };
|
|
184
|
+
}
|
|
185
|
+
if (config.mnemonic != null) {
|
|
186
|
+
try {
|
|
187
|
+
const { addr, sk } = algosdk.mnemonicToSecretKey(config.mnemonic);
|
|
188
|
+
return { addr: addr.toString(), sk };
|
|
189
|
+
} catch (cause) {
|
|
190
|
+
throw new WrongFamilyError(
|
|
191
|
+
"Algorand wallet { mnemonic } is not a valid 25-word Algorand mnemonic.",
|
|
192
|
+
{ cause }
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
throw new WrongFamilyError("Algorand wallet needs { mnemonic } (25 words) or { account }.");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// src/drivers/algorand/index.ts
|
|
200
|
+
var algorandDriver = {
|
|
201
|
+
family: "algorand",
|
|
202
|
+
resolve(opts) {
|
|
203
|
+
if (opts.chain !== "algorand") return null;
|
|
204
|
+
const algodUrl = opts.rpcUrl ?? ALGORAND_MAINNET.defaultAlgod;
|
|
205
|
+
return makeAlgorandNetwork(ALGORAND_MAINNET, algodUrl);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
function makeAlgorandNetwork(preset, algodUrl) {
|
|
209
|
+
const algod = new algosdk2.Algodv2("", algodUrl, "");
|
|
210
|
+
const indexer = new algosdk2.Indexer("", preset.defaultIndexer, "");
|
|
211
|
+
const network = preset.caip2;
|
|
212
|
+
const reader = {
|
|
213
|
+
async transactionsForAccount(account, limit) {
|
|
214
|
+
const res = await indexer.lookupAccountTransactions(account).limit(limit).do();
|
|
215
|
+
return (res.transactions ?? []).map((t) => adaptTxn(t)).filter((r) => r !== null);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const payClient = {
|
|
219
|
+
async build(transfer) {
|
|
220
|
+
const suggestedParams = await algod.getTransactionParams().do();
|
|
221
|
+
const common = {
|
|
222
|
+
sender: transfer.sender,
|
|
223
|
+
receiver: transfer.receiver,
|
|
224
|
+
amount: transfer.amount,
|
|
225
|
+
note: transfer.note,
|
|
226
|
+
suggestedParams
|
|
227
|
+
};
|
|
228
|
+
const txn = transfer.assetId === void 0 ? algosdk2.makePaymentTxnWithSuggestedParamsFromObject(common) : algosdk2.makeAssetTransferTxnWithSuggestedParamsFromObject({
|
|
229
|
+
...common,
|
|
230
|
+
assetIndex: transfer.assetId
|
|
231
|
+
});
|
|
232
|
+
return { txn, txId: txn.txID() };
|
|
233
|
+
},
|
|
234
|
+
async signSend({ txn, sk }) {
|
|
235
|
+
const signed = txn.signTxn(sk);
|
|
236
|
+
await algod.sendRawTransaction(signed).do();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
family: "algorand",
|
|
241
|
+
network,
|
|
242
|
+
supports: (n) => n === network,
|
|
243
|
+
resolveToken(token) {
|
|
244
|
+
if (token === "native") {
|
|
245
|
+
return { asset: "native", decimals: ALGO_DECIMALS, symbol: ALGO_SYMBOL };
|
|
246
|
+
}
|
|
247
|
+
if (typeof token === "string") {
|
|
248
|
+
const info = preset.tokens[token.toUpperCase()];
|
|
249
|
+
if (!info) {
|
|
250
|
+
const known = Object.keys(preset.tokens).join(", ") || "(none built in)";
|
|
251
|
+
throw new UnknownTokenError(
|
|
252
|
+
`token "${token}" isn't built in for Algorand (known: ${known}). Pass { assetId, decimals } for a custom ASA, or use 'native'.`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return { asset: algorandAssetId(info.assetId), decimals: info.decimals, symbol: info.symbol };
|
|
256
|
+
}
|
|
257
|
+
rejectForeignToken(token, "algorand", network);
|
|
258
|
+
const t = token;
|
|
259
|
+
if (typeof t.assetId !== "number" || typeof t.decimals !== "number") {
|
|
260
|
+
throw new WrongFamilyError(
|
|
261
|
+
`chain ${network} is Algorand; a custom token must be { assetId, decimals }.`
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
asset: algorandAssetId(t.assetId),
|
|
266
|
+
decimals: t.decimals,
|
|
267
|
+
...t.symbol ? { symbol: t.symbol } : {}
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
describeAsset(asset) {
|
|
271
|
+
if (asset === "native") return { symbol: ALGO_SYMBOL, decimals: ALGO_DECIMALS };
|
|
272
|
+
for (const info of Object.values(preset.tokens)) {
|
|
273
|
+
if (algorandAssetId(info.assetId) === asset) {
|
|
274
|
+
return { symbol: info.symbol, decimals: info.decimals };
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return null;
|
|
278
|
+
},
|
|
279
|
+
assertValidPayTo(payTo) {
|
|
280
|
+
if (payTo.startsWith("0x")) {
|
|
281
|
+
throw new WrongFamilyError(
|
|
282
|
+
`chain ${network} is Algorand, but payTo "${payTo}" looks like an EVM address.`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
if (!algosdk2.isValidAddress(payTo)) {
|
|
286
|
+
throw new WrongFamilyError(
|
|
287
|
+
`chain ${network} is Algorand, but payTo "${payTo}" is not a valid Algorand address.`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
bindWallet(wallet) {
|
|
292
|
+
return { _native: assertAlgorandWallet(wallet, network) };
|
|
293
|
+
},
|
|
294
|
+
async send(wallet, accept) {
|
|
295
|
+
const signer = resolveAlgorandWallet(wallet._native);
|
|
296
|
+
return payAlgorand({ client: payClient, sk: signer.sk, sender: signer.addr, accept });
|
|
297
|
+
},
|
|
298
|
+
async confirm(ref) {
|
|
299
|
+
try {
|
|
300
|
+
const info = await algosdk2.waitForConfirmation(algod, ref, 10);
|
|
301
|
+
return { height: String(info.confirmedRound ?? 0) };
|
|
302
|
+
} catch (err) {
|
|
303
|
+
throw new ConfirmationTimeoutError(`Algorand tx ${ref} did not confirm in time.`, {
|
|
304
|
+
cause: err
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
async estimateCost() {
|
|
309
|
+
return nativeCost({
|
|
310
|
+
symbol: ALGO_SYMBOL,
|
|
311
|
+
decimals: ALGO_DECIMALS,
|
|
312
|
+
fee: 1000n,
|
|
313
|
+
basis: "heuristic",
|
|
314
|
+
detail: "min fee 1000 \xB5Algos (1 transaction)"
|
|
315
|
+
});
|
|
316
|
+
},
|
|
317
|
+
async balanceOf(wallet, asset) {
|
|
318
|
+
let owner;
|
|
319
|
+
try {
|
|
320
|
+
owner = resolveAlgorandWallet(wallet._native).addr;
|
|
321
|
+
} catch {
|
|
322
|
+
return { token: null, native: null };
|
|
323
|
+
}
|
|
324
|
+
let info;
|
|
325
|
+
try {
|
|
326
|
+
info = await algod.accountInformation(owner).do();
|
|
327
|
+
} catch {
|
|
328
|
+
return { token: null, native: null };
|
|
329
|
+
}
|
|
330
|
+
const native = info.amount != null ? BigInt(info.amount) : null;
|
|
331
|
+
if (asset === "native") return { token: native, native };
|
|
332
|
+
const assetId = parseAlgorandAssetId(asset);
|
|
333
|
+
const holding = (info.assets ?? []).find((a) => Number(a.assetId) === assetId);
|
|
334
|
+
return { token: holding ? BigInt(holding.amount) : 0n, native };
|
|
335
|
+
},
|
|
336
|
+
async recipientReady(payTo, asset) {
|
|
337
|
+
if (asset === "native") return { ready: "n/a" };
|
|
338
|
+
const assetId = parseAlgorandAssetId(asset);
|
|
339
|
+
if (assetId == null) return { ready: "unknown" };
|
|
340
|
+
try {
|
|
341
|
+
const info = await algod.accountInformation(payTo).do();
|
|
342
|
+
const optedIn = (info.assets ?? []).some((a) => Number(a.assetId) === assetId);
|
|
343
|
+
return optedIn ? { ready: true } : { ready: false, reason: "NOT_OPTED_IN" };
|
|
344
|
+
} catch (e) {
|
|
345
|
+
if (/does not exist|no accounts found|404|account not found/i.test(String(e?.message ?? e))) {
|
|
346
|
+
return { ready: false, reason: "NOT_OPTED_IN" };
|
|
347
|
+
}
|
|
348
|
+
return { ready: "unknown" };
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
async verify(_ref, accept) {
|
|
352
|
+
return verifyAlgorand({ reader, accept });
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function adaptTxn(raw) {
|
|
357
|
+
const t = raw;
|
|
358
|
+
if (!t || typeof t.id !== "string") return null;
|
|
359
|
+
const note = t.note && t.note.length ? decodeNote(t.note) : void 0;
|
|
360
|
+
const base = {
|
|
361
|
+
id: t.id,
|
|
362
|
+
txType: String(t.txType ?? ""),
|
|
363
|
+
...note !== void 0 ? { note } : {},
|
|
364
|
+
...t.sender != null ? { sender: String(t.sender) } : {},
|
|
365
|
+
...typeof t.roundTime === "number" ? { roundTime: t.roundTime } : {}
|
|
366
|
+
};
|
|
367
|
+
if (t.paymentTransaction) {
|
|
368
|
+
const pt = t.paymentTransaction;
|
|
369
|
+
return {
|
|
370
|
+
...base,
|
|
371
|
+
txType: "pay",
|
|
372
|
+
...pt.receiver != null ? { receiver: String(pt.receiver) } : {},
|
|
373
|
+
...pt.amount != null ? { amount: String(pt.amount) } : {}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
if (t.assetTransferTransaction) {
|
|
377
|
+
const att = t.assetTransferTransaction;
|
|
378
|
+
return {
|
|
379
|
+
...base,
|
|
380
|
+
txType: "axfer",
|
|
381
|
+
...att.receiver != null ? { receiver: String(att.receiver) } : {},
|
|
382
|
+
...att.amount != null ? { amount: String(att.amount) } : {},
|
|
383
|
+
...att.assetId != null ? { assetId: Number(att.assetId) } : {}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
return base;
|
|
387
|
+
}
|
|
388
|
+
function decodeNote(bytes) {
|
|
389
|
+
try {
|
|
390
|
+
return new TextDecoder().decode(bytes);
|
|
391
|
+
} catch {
|
|
392
|
+
return void 0;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
export {
|
|
396
|
+
algorandDriver
|
|
397
|
+
};
|