@rozoai/intent-pay 0.1.46 → 0.1.47
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/build/constants/rozoConfig.d.ts +2 -0
- package/build/hooks/usePaymentState.d.ts +7 -0
- package/build/lib/analytics/events.d.ts +2 -0
- package/build/package.json.js +1 -1
- package/build/payment/createPaymentPayload.d.ts +12 -1
- package/build/src/components/Pages/PayWithToken/index.js +212 -171
- package/build/src/components/Pages/PayWithToken/index.js.map +1 -1
- package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js +39 -5
- package/build/src/components/Pages/Solana/PayWithSolanaToken/index.js.map +1 -1
- package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js +131 -17
- package/build/src/components/Pages/Stellar/PayWithStellarToken/index.js.map +1 -1
- package/build/src/constants/rozoConfig.js +9 -1
- package/build/src/constants/rozoConfig.js.map +1 -1
- package/build/src/hooks/usePaymentState.js +71 -16
- package/build/src/hooks/usePaymentState.js.map +1 -1
- package/build/src/lib/analytics/events.js +1 -0
- package/build/src/lib/analytics/events.js.map +1 -1
- package/build/src/payment/createPaymentPayload.js +38 -3
- package/build/src/payment/createPaymentPayload.js.map +1 -1
- package/build/src/payment/paymentEffects.js +6 -5
- package/build/src/payment/paymentEffects.js.map +1 -1
- package/build/src/utils/paymentRequestScope.js +27 -1
- package/build/src/utils/paymentRequestScope.js.map +1 -1
- package/build/src/utils/stellar/spendableBalance.js +22 -0
- package/build/src/utils/stellar/spendableBalance.js.map +1 -0
- package/build/utils/paymentRequestScope.d.ts +8 -0
- package/build/utils/stellar/index.d.ts +2 -0
- package/build/utils/stellar/spendableBalance.d.ts +16 -0
- package/package.json +1 -1
|
@@ -19,6 +19,32 @@ function isAbortError(error) {
|
|
|
19
19
|
return (error instanceof Error &&
|
|
20
20
|
(error.name === "AbortError" || /aborted/i.test(error.message)));
|
|
21
21
|
}
|
|
22
|
+
/** Provider-lifetime lock for one wallet request, including page remounts. */
|
|
23
|
+
function createPaymentAttemptLock() {
|
|
24
|
+
let activeId;
|
|
25
|
+
return {
|
|
26
|
+
tryClaim(id) {
|
|
27
|
+
if (activeId != null)
|
|
28
|
+
return false;
|
|
29
|
+
activeId = id;
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
replace(id, nextId) {
|
|
33
|
+
if (activeId !== id)
|
|
34
|
+
return false;
|
|
35
|
+
activeId = nextId;
|
|
36
|
+
return true;
|
|
37
|
+
},
|
|
38
|
+
release(id) {
|
|
39
|
+
if (activeId === id)
|
|
40
|
+
activeId = undefined;
|
|
41
|
+
},
|
|
42
|
+
clear() {
|
|
43
|
+
activeId = undefined;
|
|
44
|
+
},
|
|
45
|
+
activeId: () => activeId,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
22
48
|
function createRequestGeneration() {
|
|
23
49
|
let current = 0;
|
|
24
50
|
return {
|
|
@@ -27,5 +53,5 @@ function createRequestGeneration() {
|
|
|
27
53
|
};
|
|
28
54
|
}
|
|
29
55
|
|
|
30
|
-
export { PAYMENT_REQUEST_SCOPE, beginRequestScope, cancelRequestScope, createRequestGeneration, isAbortError };
|
|
56
|
+
export { PAYMENT_REQUEST_SCOPE, beginRequestScope, cancelRequestScope, createPaymentAttemptLock, createRequestGeneration, isAbortError };
|
|
31
57
|
//# sourceMappingURL=paymentRequestScope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymentRequestScope.js","sources":["../../../src/utils/paymentRequestScope.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,qBAAqB,GAAG;AAMrC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB;AAExC,SAAU,iBAAiB,CAAC,KAAA,GAAgB,qBAAqB,EAAA;IACrE,kBAAkB,CAAC,KAAK,CAAC;AAEzB,IAAA,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE;IAExC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC;IAEjC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B;AACH;AAEM,SAAU,kBAAkB,CAAC,KAAA,GAAgB,qBAAqB,EAAA;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;AAChC,IAAA,IAAI,CAAC,MAAM;QAAE;AAEb,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE;AACzB,IAAA,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;AACtB;AAEM,SAAU,YAAY,CAAC,KAAc,EAAA;IACzC,QACE,KAAK,YAAY,KAAK;AACtB,SAAC,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAEnE;SAegB,uBAAuB,GAAA;IACrC,IAAI,OAAO,GAAG,CAAC;IACf,OAAO;AACL,QAAA,IAAI,EAAE,MAAM,EAAE,OAAO;QACrB,OAAO,EAAE,CAAC,GAAG,KAAK,GAAG,KAAK,OAAO;KAClC;AACH;;"}
|
|
1
|
+
{"version":3,"file":"paymentRequestScope.js","sources":["../../../src/utils/paymentRequestScope.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,qBAAqB,GAAG;AAMrC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB;AAExC,SAAU,iBAAiB,CAAC,KAAA,GAAgB,qBAAqB,EAAA;IACrE,kBAAkB,CAAC,KAAK,CAAC;AAEzB,IAAA,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE;IAExC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC;IAEjC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B;AACH;AAEM,SAAU,kBAAkB,CAAC,KAAA,GAAgB,qBAAqB,EAAA;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;AAChC,IAAA,IAAI,CAAC,MAAM;QAA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+
if (!match) {
|
|
6
|
+
throw new Error("Could not determine XLM balance");
|
|
7
|
+
}
|
|
8
|
+
const [, whole, fraction = ""] = match;
|
|
9
|
+
return BigInt(whole) * STROOPS_PER_XLM + BigInt(fraction.padEnd(7, "0"));
|
|
10
|
+
}
|
|
11
|
+
function calculateStellarSpendableStroops({ nativeBalance, subentryCount = 0, numSponsored = 0, numSponsoring = 0, }) {
|
|
12
|
+
const reserveEntries = 2 + subentryCount - numSponsored + numSponsoring;
|
|
13
|
+
if (!Number.isSafeInteger(reserveEntries) || reserveEntries < 0) {
|
|
14
|
+
throw new Error("Could not determine XLM balance");
|
|
15
|
+
}
|
|
16
|
+
return (xlmToStroops(nativeBalance.balance) -
|
|
17
|
+
BigInt(reserveEntries) * STROOPS_PER_RESERVE_ENTRY -
|
|
18
|
+
xlmToStroops(nativeBalance.selling_liabilities ?? "0"));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { calculateStellarSpendableStroops };
|
|
22
|
+
//# sourceMappingURL=spendableBalance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spendableBalance.js","sources":["../../../../src/utils/stellar/spendableBalance.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,SAAW;AACnC,MAAM,yBAAyB,GAAG,QAAU;AAO5C,SAAS,YAAY,CAAC,KAAa,EAAA;IACjC,MAAM,KAAK,GAAG,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC;IACpD;IAEA,MAAM,GAAG,KAAK,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,KAAK;AACtC,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1E;SAEgB,gCAAgC,CAAC,EAC/C,aAAa,EACb,aAAa,GAAG,CAAC,EACjB,YAAY,GAAG,CAAC,EAChB,aAAa,GAAG,CAAC,GAMlB,EAAA;IACC,MAAM,cAAc,GAAG,CAAC,GAAG,aAAa,GAAG,YAAY,GAAG,aAAa;AACvE,IAAA,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,CAAC,EAAE;AAC/D,QAAA,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC;IACpD;AAEA,IAAA,QACE,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC;AACnC,QAAA,MAAM,CAAC,cAAc,CAAC,GAAG,yBAAyB;QAClD,YAAY,CAAC,aAAa,CAAC,mBAAmB,IAAI,GAAG,CAAC;AAE1D;;"}
|
|
@@ -4,6 +4,14 @@ export declare function beginRequestScope(scope?: string): {
|
|
|
4
4
|
};
|
|
5
5
|
export declare function cancelRequestScope(scope?: string): void;
|
|
6
6
|
export declare function isAbortError(error: unknown): boolean;
|
|
7
|
+
/** Provider-lifetime lock for one wallet request, including page remounts. */
|
|
8
|
+
export declare function createPaymentAttemptLock(): {
|
|
9
|
+
tryClaim(id: string): boolean;
|
|
10
|
+
replace(id: string, nextId: string): boolean;
|
|
11
|
+
release(id: string): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
activeId: () => string | undefined;
|
|
14
|
+
};
|
|
7
15
|
/**
|
|
8
16
|
* Monotonic generation counter for scoping async work to the latest
|
|
9
17
|
* request (e.g. the currently selected deposit option). AbortSignals
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export * from "./walletconnect.module";
|
|
3
|
+
export { calculateStellarSpendableStroops, calculateStellarSpendableXlm, } from "./spendableBalance";
|
|
4
|
+
export type { StellarNativeBalance } from "./spendableBalance";
|
|
3
5
|
export { defineStellarChain, isStellarChain, STELLAR_NETWORKS } from "./types";
|
|
4
6
|
export type { StellarChainConfig } from "./types";
|
|
5
7
|
export { WalletConnectAllowedMethods, WalletConnectModule, WalletConnectTargetChain, } from "./walletconnect.module";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StellarNativeBalance = {
|
|
2
|
+
balance: string;
|
|
3
|
+
selling_liabilities?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function calculateStellarSpendableStroops({ nativeBalance, subentryCount, numSponsored, numSponsoring, }: {
|
|
6
|
+
nativeBalance: StellarNativeBalance;
|
|
7
|
+
subentryCount?: number;
|
|
8
|
+
numSponsored?: number;
|
|
9
|
+
numSponsoring?: number;
|
|
10
|
+
}): bigint;
|
|
11
|
+
export declare function calculateStellarSpendableXlm(input: {
|
|
12
|
+
nativeBalance: StellarNativeBalance;
|
|
13
|
+
subentryCount?: number;
|
|
14
|
+
numSponsored?: number;
|
|
15
|
+
numSponsoring?: number;
|
|
16
|
+
}): number;
|