@t2000/sdk 4.1.0 → 4.1.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.
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1366,6 +1366,13 @@ var KeypairSigner = class {
|
|
|
1366
1366
|
}
|
|
1367
1367
|
};
|
|
1368
1368
|
|
|
1369
|
+
// src/mpp-cost.ts
|
|
1370
|
+
function parseChallengeAmount(challenge) {
|
|
1371
|
+
const raw = challenge?.request?.amount;
|
|
1372
|
+
const n = typeof raw === "string" ? Number(raw) : typeof raw === "number" ? raw : Number.NaN;
|
|
1373
|
+
return Number.isFinite(n) ? n : void 0;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1369
1376
|
// src/wallet/zkLoginSigner.ts
|
|
1370
1377
|
var ZkLoginSigner = class {
|
|
1371
1378
|
constructor(ephemeralKeypair, zkProof, userAddress, maxEpoch) {
|
|
@@ -6584,11 +6591,17 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
6584
6591
|
const signerAddress = signer.getAddress();
|
|
6585
6592
|
let paymentDigest;
|
|
6586
6593
|
let gasCostSui = 0;
|
|
6594
|
+
let chargedAmount;
|
|
6587
6595
|
const network = client.network === "testnet" ? "testnet" : "mainnet";
|
|
6588
6596
|
const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
|
|
6589
6597
|
const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
|
|
6590
6598
|
const mppx = Mppx.create({
|
|
6591
6599
|
polyfill: false,
|
|
6600
|
+
onChallenge: async (challenge) => {
|
|
6601
|
+
const parsed = parseChallengeAmount(challenge);
|
|
6602
|
+
if (parsed !== void 0) chargedAmount = parsed;
|
|
6603
|
+
return void 0;
|
|
6604
|
+
},
|
|
6592
6605
|
methods: [sui({
|
|
6593
6606
|
client,
|
|
6594
6607
|
currency: USDC,
|
|
@@ -6620,13 +6633,13 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
6620
6633
|
}
|
|
6621
6634
|
const paid = !!paymentDigest;
|
|
6622
6635
|
if (paid) {
|
|
6623
|
-
this.enforcer.recordUsage(options.maxPrice ?? 1);
|
|
6636
|
+
this.enforcer.recordUsage(chargedAmount ?? options.maxPrice ?? 1);
|
|
6624
6637
|
}
|
|
6625
6638
|
return {
|
|
6626
6639
|
status: response.status,
|
|
6627
6640
|
body,
|
|
6628
6641
|
paid,
|
|
6629
|
-
cost: paid ? options.maxPrice ?? void 0 : void 0,
|
|
6642
|
+
cost: paid ? chargedAmount ?? options.maxPrice ?? void 0 : void 0,
|
|
6630
6643
|
gasCostSui: paid ? gasCostSui : void 0,
|
|
6631
6644
|
receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
|
|
6632
6645
|
};
|