@palindromepay/sdk 1.9.5 → 1.9.6
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/LICENCE +1 -1
- package/dist/{PalindromeEscrowSDK.d.ts → PalindromePaySDK.d.ts} +7 -9
- package/dist/{PalindromeEscrowSDK.js → PalindromePaySDK.js} +17 -19
- package/dist/contract/PalindromePay.json +1180 -0
- package/dist/contract/{PalindromeEscrowWallet.json → PalindromePayWallet.json} +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/contract/PalindromeCryptoEscrow.json +0 -1180
package/LICENCE
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PALINDROME
|
|
3
|
-
*
|
|
4
|
-
* Corrected and optimized SDK matching the actual smart contract interfaces.
|
|
2
|
+
* PALINDROME Pay SDK
|
|
5
3
|
*
|
|
6
4
|
* Key contract functions:
|
|
7
5
|
* - createEscrow(token, buyer, amount, maturityDays, arbiter, title, ipfsHash, sellerWalletSig)
|
|
@@ -96,7 +94,7 @@ export declare class SDKError extends Error {
|
|
|
96
94
|
details?: ViemError | RPCError | UnknownError | Record<string, unknown>;
|
|
97
95
|
constructor(message: string, code: SDKErrorCode, details?: ViemError | RPCError | UnknownError | Record<string, unknown>);
|
|
98
96
|
}
|
|
99
|
-
export interface
|
|
97
|
+
export interface PalindromePaySDKConfig {
|
|
100
98
|
publicClient: PublicClient;
|
|
101
99
|
contractAddress: Address;
|
|
102
100
|
walletClient?: EscrowWalletClient;
|
|
@@ -212,7 +210,7 @@ export interface DisputeSubmissionStatus {
|
|
|
212
210
|
arbiter: boolean;
|
|
213
211
|
allSubmitted: boolean;
|
|
214
212
|
}
|
|
215
|
-
export declare class
|
|
213
|
+
export declare class PalindromePaySDK {
|
|
216
214
|
readonly contractAddress: Address;
|
|
217
215
|
readonly abiEscrow: Abi;
|
|
218
216
|
readonly abiWallet: Abi;
|
|
@@ -242,7 +240,7 @@ export declare class PalindromeEscrowSDK {
|
|
|
242
240
|
/** Cached multicall support status per chain (null = not yet detected) */
|
|
243
241
|
private multicallSupported;
|
|
244
242
|
private readonly STATE_NAMES;
|
|
245
|
-
constructor(config:
|
|
243
|
+
constructor(config: PalindromePaySDKConfig);
|
|
246
244
|
/**
|
|
247
245
|
* Internal logging helper that respects log level configuration
|
|
248
246
|
*/
|
|
@@ -814,7 +812,7 @@ export declare class PalindromeEscrowSDK {
|
|
|
814
812
|
*
|
|
815
813
|
* @example
|
|
816
814
|
* ```typescript
|
|
817
|
-
* const sdk = new
|
|
815
|
+
* const sdk = new PalindromePaySDK(...);
|
|
818
816
|
* const escrow = await sdk.getEscrowByIdParsed(1n);
|
|
819
817
|
* const status = sdk.getStatusLabel(escrow.state);
|
|
820
818
|
* console.log(status.label); // "Awaiting Payment"
|
|
@@ -1081,7 +1079,7 @@ export declare class PalindromeEscrowSDK {
|
|
|
1081
1079
|
*
|
|
1082
1080
|
* @example
|
|
1083
1081
|
* ```typescript
|
|
1084
|
-
* const sdk = new
|
|
1082
|
+
* const sdk = new PalindromePaySDK(...);
|
|
1085
1083
|
* const areEqual = sdk.addressEquals(
|
|
1086
1084
|
* "0xabc...",
|
|
1087
1085
|
* "0xABC..."
|
|
@@ -1214,4 +1212,4 @@ export declare class PalindromeEscrowSDK {
|
|
|
1214
1212
|
net: bigint;
|
|
1215
1213
|
}>;
|
|
1216
1214
|
}
|
|
1217
|
-
export default
|
|
1215
|
+
export default PalindromePaySDK;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright (c) 2025 Palindrome
|
|
2
|
+
// Copyright (c) 2025 Palindrome Pay
|
|
3
3
|
// Licensed under the MIT License. See LICENSE file for details.
|
|
4
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.PalindromePaySDK = exports.SDKError = exports.SDKErrorCode = exports.Role = exports.DisputeResolution = exports.EscrowState = void 0;
|
|
9
9
|
/**
|
|
10
|
-
* PALINDROME
|
|
11
|
-
*
|
|
12
|
-
* Corrected and optimized SDK matching the actual smart contract interfaces.
|
|
10
|
+
* PALINDROME Pay SDK
|
|
13
11
|
*
|
|
14
12
|
* Key contract functions:
|
|
15
13
|
* - createEscrow(token, buyer, amount, maturityDays, arbiter, title, ipfsHash, sellerWalletSig)
|
|
@@ -29,8 +27,8 @@ exports.PalindromeEscrowSDK = exports.SDKError = exports.SDKErrorCode = exports.
|
|
|
29
27
|
*/
|
|
30
28
|
const viem_1 = require("viem");
|
|
31
29
|
const actions_1 = require("viem/actions");
|
|
32
|
-
const
|
|
33
|
-
const
|
|
30
|
+
const PalindromePay_json_1 = __importDefault(require("./contract/PalindromePay.json"));
|
|
31
|
+
const PalindromePayWallet_json_1 = __importDefault(require("./contract/PalindromePayWallet.json"));
|
|
34
32
|
const USDT_json_1 = __importDefault(require("./contract/USDT.json"));
|
|
35
33
|
const client_1 = require("@apollo/client");
|
|
36
34
|
/** Type guard to check if error is a Viem error */
|
|
@@ -194,7 +192,7 @@ function addressEquals(a, b) {
|
|
|
194
192
|
// ============================================================================
|
|
195
193
|
// MAIN SDK CLASS
|
|
196
194
|
// ============================================================================
|
|
197
|
-
class
|
|
195
|
+
class PalindromePaySDK {
|
|
198
196
|
constructor(config) {
|
|
199
197
|
/** LRU cache for escrow data with automatic eviction */
|
|
200
198
|
this.escrowCache = new Map();
|
|
@@ -252,8 +250,8 @@ class PalindromeEscrowSDK {
|
|
|
252
250
|
throw new SDKError("contractAddress is required", SDKErrorCode.VALIDATION_ERROR);
|
|
253
251
|
}
|
|
254
252
|
this.contractAddress = config.contractAddress;
|
|
255
|
-
this.abiEscrow =
|
|
256
|
-
this.abiWallet =
|
|
253
|
+
this.abiEscrow = PalindromePay_json_1.default.abi;
|
|
254
|
+
this.abiWallet = PalindromePayWallet_json_1.default.abi;
|
|
257
255
|
this.abiERC20 = USDT_json_1.default.abi;
|
|
258
256
|
this.publicClient = config.publicClient;
|
|
259
257
|
this.walletClient = config.walletClient;
|
|
@@ -539,7 +537,7 @@ class PalindromeEscrowSDK {
|
|
|
539
537
|
*/
|
|
540
538
|
getWalletDomain(walletAddress) {
|
|
541
539
|
return {
|
|
542
|
-
name: "
|
|
540
|
+
name: "PalindromePayWallet",
|
|
543
541
|
version: "1",
|
|
544
542
|
chainId: this.chain.id,
|
|
545
543
|
verifyingContract: walletAddress,
|
|
@@ -662,7 +660,7 @@ class PalindromeEscrowSDK {
|
|
|
662
660
|
const encodedArgs = (0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "uint256" }], [this.contractAddress, escrowId]);
|
|
663
661
|
// Note: For accurate prediction, need actual bytecode + args hash
|
|
664
662
|
// This is a simplified version - in production, use the contract's computation
|
|
665
|
-
const initCodeHash = (0, viem_1.keccak256)((
|
|
663
|
+
const initCodeHash = (0, viem_1.keccak256)((PalindromePayWallet_json_1.default.bytecode + encodedArgs.slice(2)));
|
|
666
664
|
const raw = (0, viem_1.keccak256)((`0xff${this.contractAddress.slice(2)}${salt.slice(2)}${initCodeHash.slice(2)}`));
|
|
667
665
|
return (0, viem_1.getAddress)(`0x${raw.slice(26)}`);
|
|
668
666
|
}
|
|
@@ -764,7 +762,7 @@ class PalindromeEscrowSDK {
|
|
|
764
762
|
async getUserNonce(escrowId, signer) {
|
|
765
763
|
// Start with word 0 (nonces 0-255)
|
|
766
764
|
let wordIndex = 0n;
|
|
767
|
-
while (wordIndex <
|
|
765
|
+
while (wordIndex < PalindromePaySDK.MAX_NONCE_WORDS) {
|
|
768
766
|
const bitmap = await this.getNonceBitmap(escrowId, signer, wordIndex);
|
|
769
767
|
// If bitmap is all 1s (all NONCE_BITMAP_SIZE nonces used), check next word
|
|
770
768
|
if (bitmap === (1n << 256n) - 1n) {
|
|
@@ -791,7 +789,7 @@ class PalindromeEscrowSDK {
|
|
|
791
789
|
*/
|
|
792
790
|
getEstimatedWordCount(count) {
|
|
793
791
|
return Math.min(Math.ceil(count / 128) + 1, // Conservative estimate with buffer
|
|
794
|
-
Number(
|
|
792
|
+
Number(PalindromePaySDK.MAX_NONCE_WORDS));
|
|
795
793
|
}
|
|
796
794
|
/**
|
|
797
795
|
* Detect if chain supports Multicall3 and cache result.
|
|
@@ -1766,7 +1764,7 @@ class PalindromeEscrowSDK {
|
|
|
1766
1764
|
*
|
|
1767
1765
|
* @example
|
|
1768
1766
|
* ```typescript
|
|
1769
|
-
* const sdk = new
|
|
1767
|
+
* const sdk = new PalindromePaySDK(...);
|
|
1770
1768
|
* const escrow = await sdk.getEscrowByIdParsed(1n);
|
|
1771
1769
|
* const status = sdk.getStatusLabel(escrow.state);
|
|
1772
1770
|
* console.log(status.label); // "Awaiting Payment"
|
|
@@ -2421,7 +2419,7 @@ class PalindromeEscrowSDK {
|
|
|
2421
2419
|
*
|
|
2422
2420
|
* @example
|
|
2423
2421
|
* ```typescript
|
|
2424
|
-
* const sdk = new
|
|
2422
|
+
* const sdk = new PalindromePaySDK(...);
|
|
2425
2423
|
* const areEqual = sdk.addressEquals(
|
|
2426
2424
|
* "0xabc...",
|
|
2427
2425
|
* "0xABC..."
|
|
@@ -2698,13 +2696,13 @@ class PalindromeEscrowSDK {
|
|
|
2698
2696
|
return { fee, net: amount - fee };
|
|
2699
2697
|
}
|
|
2700
2698
|
}
|
|
2701
|
-
exports.
|
|
2699
|
+
exports.PalindromePaySDK = PalindromePaySDK;
|
|
2702
2700
|
/**
|
|
2703
2701
|
* Maximum nonce word index to prevent infinite loops.
|
|
2704
2702
|
* 100 words = 25,600 nonces per escrow per signer.
|
|
2705
2703
|
*/
|
|
2706
|
-
|
|
2704
|
+
PalindromePaySDK.MAX_NONCE_WORDS = 100n;
|
|
2707
2705
|
// ============================================================================
|
|
2708
2706
|
// EXPORT DEFAULT
|
|
2709
2707
|
// ============================================================================
|
|
2710
|
-
exports.default =
|
|
2708
|
+
exports.default = PalindromePaySDK;
|