@grvt/sdk 0.0.1 → 0.0.3
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/api/sanitizer.js +7 -0
- package/api/sanitizer.js.map +1 -1
- package/package.json +1 -1
- package/types/chain.d.ts +3 -1
- package/types/chain.js +2 -0
- package/types/chain.js.map +1 -1
- package/utils/address.d.ts +10 -0
- package/utils/address.js +21 -0
- package/utils/address.js.map +1 -1
package/api/sanitizer.js
CHANGED
|
@@ -21,6 +21,8 @@ function sanitizeDepositHistoryResponse(response) {
|
|
|
21
21
|
...deposit,
|
|
22
22
|
from_address: sanitizeNullableAddress(deposit.from_address),
|
|
23
23
|
to_account_id: sanitizeNullableAddress(deposit.to_account_id),
|
|
24
|
+
l_1_hash: sanitizeNullableTransactionHash(deposit.l_1_hash),
|
|
25
|
+
l_2_hash: sanitizeNullableTransactionHash(deposit.l_2_hash),
|
|
24
26
|
})),
|
|
25
27
|
};
|
|
26
28
|
}
|
|
@@ -31,10 +33,15 @@ function sanitizeWithdrawalHistoryResponse(response) {
|
|
|
31
33
|
...withdrawal,
|
|
32
34
|
from_account_id: sanitizeNullableAddress(withdrawal.from_account_id),
|
|
33
35
|
to_eth_address: sanitizeNullableAddress(withdrawal.to_eth_address),
|
|
36
|
+
l_1_hash: sanitizeNullableTransactionHash(withdrawal.l_1_hash),
|
|
37
|
+
l_2_hash: sanitizeNullableTransactionHash(withdrawal.l_2_hash),
|
|
34
38
|
})),
|
|
35
39
|
};
|
|
36
40
|
}
|
|
37
41
|
function sanitizeNullableAddress(address) {
|
|
38
42
|
return address ? (0, address_1.sanitizeEvmAddress)(address) : undefined;
|
|
39
43
|
}
|
|
44
|
+
function sanitizeNullableTransactionHash(transactionHash) {
|
|
45
|
+
return transactionHash ? (0, address_1.sanitizeTransactionHash)(transactionHash) : undefined;
|
|
46
|
+
}
|
|
40
47
|
//# sourceMappingURL=sanitizer.js.map
|
package/api/sanitizer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../src/api/sanitizer.ts"],"names":[],"mappings":";;AAOA,0EAWC;AAED,
|
|
1
|
+
{"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../src/api/sanitizer.ts"],"names":[],"mappings":";;AAOA,0EAWC;AAED,wEAaC;AAED,8EAaC;AA3CD,8CAA+E;AAE/E,SAAgB,+BAA+B,CAC7C,QAAqC;IAErC,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC1C,GAAG,QAAQ;YACX,eAAe,EAAE,uBAAuB,CAAC,QAAQ,CAAC,eAAe,CAAC;YAClE,aAAa,EAAE,uBAAuB,CAAC,QAAQ,CAAC,aAAa,CAAC;SAC/D,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,SAAgB,8BAA8B,CAC5C,QAAoC;IAEpC,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACzC,GAAG,OAAO;YACV,YAAY,EAAE,uBAAuB,CAAC,OAAO,CAAC,YAAY,CAAC;YAC3D,aAAa,EAAE,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC;YAC7D,QAAQ,EAAE,+BAA+B,CAAC,OAAO,CAAC,QAAQ,CAAC;YAC3D,QAAQ,EAAE,+BAA+B,CAAC,OAAO,CAAC,QAAQ,CAAC;SAC5D,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,SAAgB,iCAAiC,CAC/C,QAAuC;IAEvC,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAC5C,GAAG,UAAU;YACb,eAAe,EAAE,uBAAuB,CAAC,UAAU,CAAC,eAAe,CAAC;YACpE,cAAc,EAAE,uBAAuB,CAAC,UAAU,CAAC,cAAc,CAAC;YAClE,QAAQ,EAAE,+BAA+B,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC9D,QAAQ,EAAE,+BAA+B,CAAC,UAAU,CAAC,QAAQ,CAAC;SAC/D,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,OAA2B;IAC1D,OAAO,OAAO,CAAC,CAAC,CAAC,IAAA,4BAAkB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED,SAAS,+BAA+B,CAAC,eAAmC;IAC1E,OAAO,eAAe,CAAC,CAAC,CAAC,IAAA,iCAAuB,EAAC,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
package/types/chain.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare enum EChain {
|
|
|
8
8
|
ZKSYNC_ERA = "324",
|
|
9
9
|
SOLANA = "solana",
|
|
10
10
|
TRON = "tron",
|
|
11
|
+
KAIA = "8217",
|
|
11
12
|
ARBITRUM_SEPOLIA = "421614",
|
|
12
13
|
BNB_TESTNET = "97",
|
|
13
14
|
BASE_SEPOLIA = "84532",
|
|
@@ -16,5 +17,6 @@ export declare enum EChain {
|
|
|
16
17
|
POLYGON_ZKEVM_CARDONA_TEST = "2442",
|
|
17
18
|
ZKSYNC_SEPOLIA = "300",
|
|
18
19
|
SOLANA_TESTNET = "solana_test",
|
|
19
|
-
TRON_TESTNET = "tron_test"
|
|
20
|
+
TRON_TESTNET = "tron_test",
|
|
21
|
+
KAIA_TESTNET = "1001"
|
|
20
22
|
}
|
package/types/chain.js
CHANGED
|
@@ -13,6 +13,7 @@ var EChain;
|
|
|
13
13
|
EChain["ZKSYNC_ERA"] = "324";
|
|
14
14
|
EChain["SOLANA"] = "solana";
|
|
15
15
|
EChain["TRON"] = "tron";
|
|
16
|
+
EChain["KAIA"] = "8217";
|
|
16
17
|
// Testnet
|
|
17
18
|
EChain["ARBITRUM_SEPOLIA"] = "421614";
|
|
18
19
|
EChain["BNB_TESTNET"] = "97";
|
|
@@ -23,5 +24,6 @@ var EChain;
|
|
|
23
24
|
EChain["ZKSYNC_SEPOLIA"] = "300";
|
|
24
25
|
EChain["SOLANA_TESTNET"] = "solana_test";
|
|
25
26
|
EChain["TRON_TESTNET"] = "tron_test";
|
|
27
|
+
EChain["KAIA_TESTNET"] = "1001";
|
|
26
28
|
})(EChain || (exports.EChain = EChain = {}));
|
|
27
29
|
//# sourceMappingURL=chain.js.map
|
package/types/chain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/types/chain.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../src/types/chain.ts"],"names":[],"mappings":";;;AAAA,IAAY,MAwBX;AAxBD,WAAY,MAAM;IAChB,UAAU;IACV,gCAAsB,CAAA;IACtB,gCAAsB,CAAA;IACtB,uBAAa,CAAA;IACb,wBAAc,CAAA;IACd,yBAAe,CAAA;IACf,gCAAsB,CAAA;IACtB,4BAAkB,CAAA;IAClB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;IACb,uBAAa,CAAA;IAEb,UAAU;IACV,qCAA2B,CAAA;IAC3B,4BAAkB,CAAA;IAClB,gCAAsB,CAAA;IACtB,uCAA6B,CAAA;IAC7B,gCAAsB,CAAA;IACtB,6CAAmC,CAAA;IACnC,gCAAsB,CAAA;IACtB,wCAA8B,CAAA;IAC9B,oCAA0B,CAAA;IAC1B,+BAAqB,CAAA;AACvB,CAAC,EAxBW,MAAM,sBAAN,MAAM,QAwBjB"}
|
package/utils/address.d.ts
CHANGED
|
@@ -8,3 +8,13 @@
|
|
|
8
8
|
* @returns The sanitized address
|
|
9
9
|
*/
|
|
10
10
|
export declare function sanitizeEvmAddress(address: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Sanitize a transaction hash to:
|
|
13
|
+
* - trim the transaction hash
|
|
14
|
+
* - lowercase the transaction hash
|
|
15
|
+
* - add 0 padding to the left if it's less than 64 characters
|
|
16
|
+
* - add 0x prefix if it doesn't have it
|
|
17
|
+
* @param transactionHash - The transaction hash to sanitize
|
|
18
|
+
* @returns The sanitized transaction hash
|
|
19
|
+
*/
|
|
20
|
+
export declare function sanitizeTransactionHash(transactionHash: string): string;
|
package/utils/address.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sanitizeEvmAddress = sanitizeEvmAddress;
|
|
4
|
+
exports.sanitizeTransactionHash = sanitizeTransactionHash;
|
|
4
5
|
/**
|
|
5
6
|
* Sanitize an EVM address to:
|
|
6
7
|
* - trim the address
|
|
@@ -23,4 +24,24 @@ function sanitizeEvmAddress(address) {
|
|
|
23
24
|
address = address.toLowerCase();
|
|
24
25
|
return address;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Sanitize a transaction hash to:
|
|
29
|
+
* - trim the transaction hash
|
|
30
|
+
* - lowercase the transaction hash
|
|
31
|
+
* - add 0 padding to the left if it's less than 64 characters
|
|
32
|
+
* - add 0x prefix if it doesn't have it
|
|
33
|
+
* @param transactionHash - The transaction hash to sanitize
|
|
34
|
+
* @returns The sanitized transaction hash
|
|
35
|
+
*/
|
|
36
|
+
function sanitizeTransactionHash(transactionHash) {
|
|
37
|
+
// 1. Trim the transaction hash
|
|
38
|
+
transactionHash = transactionHash.trim();
|
|
39
|
+
// 2. Remove the 0x prefix if it exists
|
|
40
|
+
transactionHash = transactionHash.replace(/^0x/, '');
|
|
41
|
+
// 3. Add 0 padding to the left if it's less than 64 characters
|
|
42
|
+
transactionHash = transactionHash.padStart(64, '0');
|
|
43
|
+
// 4. Add 0x prefix if it doesn't have it
|
|
44
|
+
transactionHash = `0x${transactionHash}`;
|
|
45
|
+
return transactionHash;
|
|
46
|
+
}
|
|
26
47
|
//# sourceMappingURL=address.js.map
|
package/utils/address.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;AASA,gDAYC;
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/utils/address.ts"],"names":[],"mappings":";;AASA,gDAYC;AAWD,0DAUC;AA1CD;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,sBAAsB;IACtB,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IACzB,uCAAuC;IACvC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,+DAA+D;IAC/D,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpC,yCAAyC;IACzC,OAAO,GAAG,KAAK,OAAO,EAAE,CAAC;IACzB,gEAAgE;IAChE,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,uBAAuB,CAAC,eAAuB;IAC7D,+BAA+B;IAC/B,eAAe,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;IACzC,uCAAuC;IACvC,eAAe,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrD,+DAA+D;IAC/D,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACpD,yCAAyC;IACzC,eAAe,GAAG,KAAK,eAAe,EAAE,CAAC;IACzC,OAAO,eAAe,CAAC;AACzB,CAAC"}
|