llama-pay-sdk 1.0.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.
Files changed (76) hide show
  1. package/lib/data/DoraApiClient.d.ts +30 -0
  2. package/lib/data/DoraApiClient.d.ts.map +1 -0
  3. package/lib/data/DoraApiClient.js +34 -0
  4. package/lib/data/DoraApiClient.js.map +1 -0
  5. package/lib/data/HttpClient.d.ts +30 -0
  6. package/lib/data/HttpClient.d.ts.map +1 -0
  7. package/lib/data/HttpClient.js +75 -0
  8. package/lib/data/HttpClient.js.map +1 -0
  9. package/lib/data/MerapiClient.d.ts +77 -0
  10. package/lib/data/MerapiClient.d.ts.map +1 -0
  11. package/lib/data/MerapiClient.js +106 -0
  12. package/lib/data/MerapiClient.js.map +1 -0
  13. package/lib/index.d.ts +13 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +8 -0
  16. package/lib/index.js.map +1 -0
  17. package/lib/models/Balance.d.ts +16 -0
  18. package/lib/models/Balance.d.ts.map +1 -0
  19. package/lib/models/Balance.js +3 -0
  20. package/lib/models/Balance.js.map +1 -0
  21. package/lib/models/FeatureFlags.d.ts +5 -0
  22. package/lib/models/FeatureFlags.d.ts.map +1 -0
  23. package/lib/models/FeatureFlags.js +3 -0
  24. package/lib/models/FeatureFlags.js.map +1 -0
  25. package/lib/models/IBinInfo.d.ts +25 -0
  26. package/lib/models/IBinInfo.d.ts.map +1 -0
  27. package/lib/models/IBinInfo.js +3 -0
  28. package/lib/models/IBinInfo.js.map +1 -0
  29. package/lib/models/IMultisigWallet.d.ts +36 -0
  30. package/lib/models/IMultisigWallet.d.ts.map +1 -0
  31. package/lib/models/IMultisigWallet.js +3 -0
  32. package/lib/models/IMultisigWallet.js.map +1 -0
  33. package/lib/models/ITokenInfo.d.ts +10 -0
  34. package/lib/models/ITokenInfo.d.ts.map +1 -0
  35. package/lib/models/ITokenInfo.js +3 -0
  36. package/lib/models/ITokenInfo.js.map +1 -0
  37. package/lib/models/ITransaction.d.ts +40 -0
  38. package/lib/models/ITransaction.d.ts.map +1 -0
  39. package/lib/models/ITransaction.js +3 -0
  40. package/lib/models/ITransaction.js.map +1 -0
  41. package/lib/models/IUser.d.ts +10 -0
  42. package/lib/models/IUser.d.ts.map +1 -0
  43. package/lib/models/IUser.js +3 -0
  44. package/lib/models/IUser.js.map +1 -0
  45. package/lib/models/SimpleMultisigTransactionData.d.ts +29 -0
  46. package/lib/models/SimpleMultisigTransactionData.d.ts.map +1 -0
  47. package/lib/models/SimpleMultisigTransactionData.js +3 -0
  48. package/lib/models/SimpleMultisigTransactionData.js.map +1 -0
  49. package/lib/models/Transaction.d.ts +30 -0
  50. package/lib/models/Transaction.d.ts.map +1 -0
  51. package/lib/models/Transaction.js +3 -0
  52. package/lib/models/Transaction.js.map +1 -0
  53. package/lib/models/Wallet.d.ts +15 -0
  54. package/lib/models/Wallet.d.ts.map +1 -0
  55. package/lib/models/Wallet.js +3 -0
  56. package/lib/models/Wallet.js.map +1 -0
  57. package/lib/util.d.ts +9 -0
  58. package/lib/util.d.ts.map +1 -0
  59. package/lib/util.js +72 -0
  60. package/lib/util.js.map +1 -0
  61. package/package.json +27 -0
  62. package/src/data/DoraApiClient.ts +58 -0
  63. package/src/data/HttpClient.ts +125 -0
  64. package/src/data/MerapiClient.ts +194 -0
  65. package/src/index.ts +29 -0
  66. package/src/models/Balance.ts +16 -0
  67. package/src/models/FeatureFlags.ts +4 -0
  68. package/src/models/IBinInfo.ts +24 -0
  69. package/src/models/IMultisigWallet.ts +40 -0
  70. package/src/models/ITokenInfo.ts +9 -0
  71. package/src/models/ITransaction.ts +47 -0
  72. package/src/models/IUser.ts +9 -0
  73. package/src/models/SimpleMultisigTransactionData.ts +28 -0
  74. package/src/models/Transaction.ts +31 -0
  75. package/src/models/Wallet.ts +17 -0
  76. package/tsconfig.json +18 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITransaction.js","sourceRoot":"","sources":["../../src/models/ITransaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export type IUser = {
2
+ id: string | number;
3
+ email: string;
4
+ phone: string | null;
5
+ name: string | null;
6
+ publicAddress: string | null;
7
+ createdOn: string;
8
+ updatedOn: string;
9
+ };
10
+ //# sourceMappingURL=IUser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IUser.d.ts","sourceRoot":"","sources":["../../src/models/IUser.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IAChB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IUser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IUser.js","sourceRoot":"","sources":["../../src/models/IUser.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ export type SimpleMultisigTransactionData = {
2
+ types: {
3
+ EIP712Domain: {
4
+ name: string;
5
+ type: string;
6
+ }[];
7
+ MultiSigTransaction: {
8
+ name: string;
9
+ type: string;
10
+ }[];
11
+ };
12
+ domain: {
13
+ name: string;
14
+ version: string;
15
+ chainId: number;
16
+ verifyingContract: string;
17
+ salt: string;
18
+ };
19
+ primaryType: string;
20
+ message: {
21
+ executor: string;
22
+ nonce: number;
23
+ gasLimit: number;
24
+ destination: string;
25
+ value: string;
26
+ data: string;
27
+ };
28
+ };
29
+ //# sourceMappingURL=SimpleMultisigTransactionData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleMultisigTransactionData.d.ts","sourceRoot":"","sources":["../../src/models/SimpleMultisigTransactionData.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,6BAA6B,GAAG;IACxC,KAAK,EAAE;QACH,YAAY,EAAE;YACV,IAAI,EAAE,MAAM,CAAA;YACZ,IAAI,EAAE,MAAM,CAAA;SACf,EAAE,CAAA;QACH,mBAAmB,EAAE;YACjB,IAAI,EAAE,MAAM,CAAA;YACZ,IAAI,EAAE,MAAM,CAAA;SACf,EAAE,CAAA;KACN,CAAA;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,iBAAiB,EAAE,MAAM,CAAA;QACzB,IAAI,EAAE,MAAM,CAAA;KACf,CAAA;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE;QACL,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;QACb,QAAQ,EAAE,MAAM,CAAA;QAChB,WAAW,EAAE,MAAM,CAAA;QACnB,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,EAAE,MAAM,CAAA;KACf,CAAA;CACJ,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=SimpleMultisigTransactionData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleMultisigTransactionData.js","sourceRoot":"","sources":["../../src/models/SimpleMultisigTransactionData.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ export type Transaction = {
2
+ hash: string;
3
+ created_at: string;
4
+ from: string;
5
+ to: string;
6
+ value: string;
7
+ is_from: boolean;
8
+ tokenSymbol: string;
9
+ tokenAddress?: string;
10
+ };
11
+ export type NativeTransaction = {
12
+ hash: string;
13
+ created_at: string;
14
+ from: string;
15
+ to: string;
16
+ value: string;
17
+ is_from: boolean;
18
+ };
19
+ export type ERC20Transaction = {
20
+ hash: string;
21
+ method: string;
22
+ created_at: string;
23
+ from: string;
24
+ to: string;
25
+ amount: string;
26
+ is_from: boolean;
27
+ token: string;
28
+ contract: string;
29
+ };
30
+ //# sourceMappingURL=Transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/models/Transaction.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/models/Transaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ export type HDWallet = {
2
+ id: string;
3
+ name: string;
4
+ mnemonic: string;
5
+ };
6
+ export type Account = {
7
+ id: string;
8
+ name: string;
9
+ address: string;
10
+ type: 'hd' | 'single';
11
+ walletId?: string;
12
+ privateKey?: string;
13
+ derivationPath?: string;
14
+ };
15
+ //# sourceMappingURL=Wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wallet.d.ts","sourceRoot":"","sources":["../../src/models/Wallet.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAA;IAGrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Wallet.js","sourceRoot":"","sources":["../../src/models/Wallet.ts"],"names":[],"mappings":""}
package/lib/util.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Balance } from '@/models/Balance';
2
+ export declare function clipMiddle(str: string, maxLength?: number): string;
3
+ export declare function portfolioChangePctWeighted(tokens: Balance[]): number;
4
+ export declare function hexToRgba(hex: string, opacity: number): string;
5
+ export declare function isENSFormat(name: string): boolean;
6
+ export declare function throttle<T extends unknown[]>(callback: (...args: T) => void, delay: number): (...args: T) => void;
7
+ export declare function isValidCreditCard(num: string): boolean;
8
+ export declare function normalize(value: number, min: number, max: number): number;
9
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAK,UAIrD;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAUpE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAcrD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EACxC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EAC9B,KAAK,EAAE,MAAM,IAIL,GAAG,MAAM,CAAC,UAYrB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAmBtD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzE"}
package/lib/util.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clipMiddle = clipMiddle;
4
+ exports.portfolioChangePctWeighted = portfolioChangePctWeighted;
5
+ exports.hexToRgba = hexToRgba;
6
+ exports.isENSFormat = isENSFormat;
7
+ exports.throttle = throttle;
8
+ exports.isValidCreditCard = isValidCreditCard;
9
+ exports.normalize = normalize;
10
+ function clipMiddle(str, maxLength = 20) {
11
+ if (str.length <= maxLength)
12
+ return str;
13
+ const half = Math.floor((maxLength - 3) / 2);
14
+ return str.slice(0, half) + '...' + str.slice(str.length - half);
15
+ }
16
+ function portfolioChangePctWeighted(tokens) {
17
+ const totalValue = tokens.reduce((s, t) => s + (t.currentValue || 0), 0);
18
+ if (totalValue === 0)
19
+ return 0;
20
+ const weightedSum = tokens.reduce((s, t) => s + (t.currentValue || 0) * (t.priceChangePercentange24h || 0), 0);
21
+ return weightedSum / totalValue;
22
+ }
23
+ function hexToRgba(hex, opacity) {
24
+ let cleaned = hex.replace('#', '');
25
+ if (cleaned.length === 3) {
26
+ cleaned = cleaned
27
+ .split('')
28
+ .map((c) => c + c)
29
+ .join('');
30
+ }
31
+ const r = parseInt(cleaned.substring(0, 2), 16);
32
+ const g = parseInt(cleaned.substring(2, 4), 16);
33
+ const b = parseInt(cleaned.substring(4, 6), 16);
34
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
35
+ }
36
+ function isENSFormat(name) {
37
+ return /^(?:[a-z0-9-]+\.)+[a-z]{2,}$/.test(name);
38
+ }
39
+ function throttle(callback, delay) {
40
+ let isWaiting = false;
41
+ return (...args) => {
42
+ if (isWaiting) {
43
+ return;
44
+ }
45
+ callback(...args);
46
+ isWaiting = true;
47
+ setTimeout(() => {
48
+ isWaiting = false;
49
+ }, delay);
50
+ };
51
+ }
52
+ function isValidCreditCard(num) {
53
+ const str = num.replace(/\D/g, '');
54
+ let sum = 0;
55
+ let shouldDouble = false;
56
+ // Loop from right to left
57
+ for (let i = str.length - 1; i >= 0; i--) {
58
+ let digit = parseInt(str[i], 10);
59
+ if (shouldDouble) {
60
+ digit *= 2;
61
+ if (digit > 9)
62
+ digit -= 9;
63
+ }
64
+ sum += digit;
65
+ shouldDouble = !shouldDouble;
66
+ }
67
+ return sum % 10 === 0;
68
+ }
69
+ function normalize(value, min, max) {
70
+ return (value - min) / (max - min);
71
+ }
72
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAEA,gCAIC;AAED,gEAUC;AAED,8BAcC;AAED,kCAEC;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EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAEhC,IAAI,YAAY,EAAE,CAAC;YACf,KAAK,IAAI,CAAC,CAAA;YACV,IAAI,KAAK,GAAG,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAA;QAC7B,CAAC;QAED,GAAG,IAAI,KAAK,CAAA;QACZ,YAAY,GAAG,CAAC,YAAY,CAAA;IAChC,CAAC;IAED,OAAO,GAAG,GAAG,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC;AAED,SAAgB,SAAS,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC7D,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;AACtC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "llama-pay-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official SDK for ethpar services. For more details visit https://www.ethpar.com/#join-network",
5
+ "main": "./lib/index.js",
6
+ "types": "./lib/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "clean": "rm -rf ./lib/",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/ethpar/llama-pay-SDK-react-native.git"
15
+ },
16
+ "keywords": [
17
+ "ethpar",
18
+ "llama-pay"
19
+ ],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "type": "commonjs",
23
+ "devDependencies": {
24
+ "@types/node": "^24.9.1",
25
+ "typescript": "^5.9.3"
26
+ }
27
+ }
@@ -0,0 +1,58 @@
1
+ import { ERC20Transaction, NativeTransaction } from '../models/Transaction'
2
+ import { HttpClient } from './HttpClient'
3
+
4
+ type Headers = { [key: string]: string }
5
+
6
+ export class DoraApiClient {
7
+ http: HttpClient
8
+ headers: Headers = {
9
+ 'Content-Type': 'application/json',
10
+ Accept: 'application/json'
11
+ }
12
+
13
+ constructor() {
14
+ const doraUrl = 'https://dora.testnet.ethpar.net/api'
15
+ this.http = new HttpClient(doraUrl, this.headers)
16
+ }
17
+
18
+ getTransactions = (
19
+ address: string,
20
+ params?: { offset: number; size: number }
21
+ ): Promise<{
22
+ data: NativeTransaction[]
23
+ totalCount: number
24
+ pageSize: number
25
+ offset: number
26
+ }> => {
27
+ if (!params) {
28
+ params = {
29
+ offset: 0,
30
+ size: 1000
31
+ }
32
+ }
33
+ return this.http.get(
34
+ `/account/txlist/${address}?offset=${params.offset}&pageSize=${params.size}`
35
+ )
36
+ }
37
+
38
+ getERC20Transactions = (
39
+ address: string,
40
+ contract: string,
41
+ params?: { offset: number; size: number }
42
+ ): Promise<{
43
+ data: ERC20Transaction[]
44
+ totalCount: number
45
+ pageSize: number
46
+ offset: number
47
+ }> => {
48
+ if (!params) {
49
+ params = {
50
+ offset: 0,
51
+ size: 1000
52
+ }
53
+ }
54
+ return this.http.get(
55
+ `/account/txlist/erc20/${address}?contract=${contract}?offset=${params.offset}&pageSize=${params.size}`
56
+ )
57
+ }
58
+ }
@@ -0,0 +1,125 @@
1
+ type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
2
+
3
+ type Body = Record<string, any> | Record<string, any>[] | string;
4
+
5
+ type Request = {
6
+ url: string
7
+ method: HttpMethod
8
+ headers: Record<string, string>,
9
+ body?: BodyInit
10
+ }
11
+
12
+ interface RequestConfig {
13
+ headers?: Record<string, string>;
14
+ beforeRequest?: (req: Request) => void | Promise<void>;
15
+ afterRequest?: (response: Response) => void | Promise<void>;
16
+ }
17
+
18
+ export class HttpClient {
19
+ private baseUrl: string;
20
+ private defaultHeaders: Record<string, string>;
21
+ private globalBeforeRequest?: (
22
+ req: Request
23
+ ) => void | Promise<void>;
24
+ private globalAfterRequest?: (response: Response) => void | Promise<void>;
25
+
26
+ constructor(baseUrl: string, defaultHeaders: Record<string, string> = {}) {
27
+ this.baseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
28
+ this.defaultHeaders = defaultHeaders;
29
+ }
30
+
31
+ setBeforeRequestCallback(
32
+ beforeRequest?: (req: Request) => void | Promise<void>,
33
+ ) {
34
+ this.globalBeforeRequest = beforeRequest;
35
+ }
36
+
37
+ setAfterRequestCallback(
38
+ afterRequest?: (response: Response) => void | Promise<void>,
39
+ ) {
40
+ this.globalAfterRequest = afterRequest;
41
+ }
42
+
43
+ setDefaultHeaders(headers: Record<string, string>) {
44
+ this.defaultHeaders = headers;
45
+ }
46
+
47
+ private async request<T>(
48
+ endpoint: string,
49
+ method: HttpMethod,
50
+ body?: Body,
51
+ config: RequestConfig = {},
52
+ ): Promise<T> {
53
+ const url = `${this.baseUrl}${endpoint}`;
54
+ const headers = {
55
+ ...this.defaultHeaders,
56
+ ...config.headers,
57
+ };
58
+
59
+ if (body && typeof body === "object") {
60
+ body = JSON.stringify(body);
61
+ }
62
+
63
+ const request: Request = {
64
+ url,
65
+ headers,
66
+ method,
67
+ body
68
+ }
69
+ if (this.globalBeforeRequest) {
70
+ await this.globalBeforeRequest(request);
71
+ }
72
+
73
+ if (config.beforeRequest) {
74
+ await config.beforeRequest(request);
75
+ }
76
+ try {
77
+ const response = await fetch(request.url, {
78
+ method: request.method,
79
+ headers: request.headers,
80
+ body: request.body,
81
+ });
82
+
83
+ if (this.globalAfterRequest) {
84
+ await this.globalAfterRequest(response);
85
+ }
86
+
87
+ if (config.afterRequest) {
88
+ await config.afterRequest(response);
89
+ }
90
+
91
+ const responseBody = await response.json().catch(e => undefined);
92
+
93
+ return responseBody;
94
+ } catch (error) {
95
+ if (error instanceof Error) {
96
+ throw error;
97
+ }
98
+ throw new Error(String(error));
99
+ }
100
+ }
101
+
102
+ async get<T>(endpoint: string, body?: Body, config?: RequestConfig): Promise<T> {
103
+ return this.request(endpoint, "GET", body, config) as T;
104
+ }
105
+
106
+ async post<T>(
107
+ endpoint: string,
108
+ body?: Body,
109
+ config?: RequestConfig,
110
+ ): Promise<T> {
111
+ return this.request(endpoint, "POST", body, config) as T;
112
+ }
113
+
114
+ async put<T>(
115
+ endpoint: string,
116
+ body: Body,
117
+ config?: RequestConfig,
118
+ ): Promise<T> {
119
+ return this.request(endpoint, "PUT", body, config) as T;
120
+ }
121
+
122
+ async delete<T>(endpoint: string, config?: RequestConfig): Promise<T> {
123
+ return this.request(endpoint, "DELETE", undefined, config) as T;
124
+ }
125
+ }
@@ -0,0 +1,194 @@
1
+ import { BalanceResponse } from '../models/Balance'
2
+ import { FeatureFlags } from '../models/FeatureFlags'
3
+ import {
4
+ ICreditCardMultisigWallet,
5
+ IGeneralMultisigWallet
6
+ } from '../models/IMultisigWallet'
7
+ import { ITokenInfo } from '../models/ITokenInfo'
8
+ import { ITransaction } from '../models/ITransaction'
9
+ import { IUser } from '../models/IUser'
10
+ import { HttpClient } from './HttpClient'
11
+
12
+ type Headers = { [key: string]: string }
13
+
14
+ type AuthTokenProvider = () => Promise<string | null>
15
+
16
+ type Response<T> = {
17
+ result: 'ok' | 'error'
18
+ error: {
19
+ code: string
20
+ server_message: string
21
+ } | null
22
+ data: T
23
+ }
24
+
25
+ export class MerapiClient {
26
+ http: HttpClient
27
+ headers: Headers = {
28
+ 'Content-Type': 'application/json',
29
+ Accept: 'application/json'
30
+ }
31
+ afterRequestCallback?: (responseBody: any, req: globalThis.Response) => void | Promise<void>
32
+ authTokenProvider?: AuthTokenProvider
33
+
34
+ constructor(baseUrl: string) {
35
+ this.http = new HttpClient(baseUrl, this.headers)
36
+ this.http.setBeforeRequestCallback(async (req) => {
37
+ const authToken = await this.authTokenProvider?.call(null)
38
+ if (authToken) {
39
+ req.headers['Authorization'] = authToken
40
+ }
41
+ })
42
+ this.http.setAfterRequestCallback(async (res) => {
43
+ if (!res.ok) {
44
+ const body = await res.json().catch((e) => null)
45
+ this.afterRequestCallback?.call(null, body, res)
46
+ throw new Error(
47
+ body?.error?.server_message ||
48
+ body?.error?.code ||
49
+ res.statusText
50
+ )
51
+ }
52
+ })
53
+ }
54
+
55
+ setAuthTokenProvider(provider: AuthTokenProvider) {
56
+ this.authTokenProvider = provider
57
+ }
58
+
59
+ generateLoginCode = (params: {
60
+ contact: string
61
+ password?: string
62
+ }): Promise<void> => {
63
+ return this.http.post('/wallet/login/code', params)
64
+ }
65
+
66
+ confirmLoginCode = (params: {
67
+ contact: string
68
+ code: string
69
+ }): Promise<{
70
+ sessionKey: string
71
+ }> => {
72
+ return this.http
73
+ .post<Response<{ sessionKey: string }>>(
74
+ '/wallet/login/confirm',
75
+ params
76
+ )
77
+ .then((data) => data.data)
78
+ }
79
+
80
+ getCurrentUser = (): Promise<IUser> => {
81
+ return this.http.get('/wallet/users/me')
82
+ }
83
+
84
+ getBalances = (
85
+ address: string,
86
+ tokens: {
87
+ tokenAddress: string | null
88
+ }[]
89
+ ): Promise<BalanceResponse[]> => {
90
+ return this.http.post(`/wallet/blockchain/${address}/get-balance`, {
91
+ tokens
92
+ })
93
+ }
94
+
95
+ setUserPublicAddress = async (params: { address: string }) => {
96
+ await this.http.post('/wallet/users/set-address', params)
97
+ }
98
+
99
+ getDefaultTokens = (): Promise<ITokenInfo[]> => {
100
+ return this.http.get(`/wallet/blockchain/tokens`)
101
+ }
102
+
103
+ createMultisigWallet = (params: {
104
+ name: string
105
+ signers: string[]
106
+ threshold: number
107
+ }): Promise<IGeneralMultisigWallet> => {
108
+ return this.http.post('/wallet/wallets', params)
109
+ }
110
+
111
+ acceptMultisigWallet = async (walletId: string) => {
112
+ await this.http.post(`/wallet/wallets/${walletId}/accept`, { walletId })
113
+ }
114
+
115
+ getMultisigWallets = (): Promise<IGeneralMultisigWallet[]> => {
116
+ return this.http.get('/wallet/wallets')
117
+ }
118
+
119
+ createMultisigTransaction = (params: {
120
+ walletId: string
121
+ assetType: 'native' | 'erc20'
122
+ to: string
123
+ amount: string
124
+ tokenAddress: string | null
125
+ remark: string | null
126
+ }): Promise<ITransaction> => {
127
+ return this.http.post('/wallet/tx', params)
128
+ }
129
+
130
+ getMultisigWalletTransactions = (
131
+ walletId: string
132
+ ): Promise<ITransaction[]> => {
133
+ return this.http.get(`/wallet/wallets/${walletId}/tx`)
134
+ }
135
+
136
+ getMultisigWalletTransaction = async (
137
+ txId: string
138
+ ): Promise<ITransaction> => {
139
+ return this.http.get(`/wallet/tx/${txId}`)
140
+ }
141
+
142
+ addMultisigTxSignature = (
143
+ txId: string,
144
+ data: { txid: string; address: string; signature: string }
145
+ ): Promise<ITransaction> => {
146
+ return this.http.post(`/wallet/tx/${txId}/signature`, data)
147
+ }
148
+
149
+ executeTransaction = (txId: string): Promise<ITransaction> => {
150
+ return this.http.post(`/wallet/tx/${txId}/execute`, { txid: txId })
151
+ }
152
+
153
+ getCCWallet = (): Promise<ICreditCardMultisigWallet | null> => {
154
+ return this.http.get('/wallet/ccwallet').then((wallet) => {
155
+ if (wallet && Object.keys(wallet).length > 0) {
156
+ return wallet as ICreditCardMultisigWallet
157
+ }
158
+ return null
159
+ })
160
+ }
161
+
162
+ getCCWalletTransactions = (walletId: string): Promise<ITransaction[]> => {
163
+ return this.http.get(`/wallet/ccwallet/${walletId}/tx`)
164
+ }
165
+
166
+ createCCWallet = (params: {
167
+ pan: string
168
+ }): Promise<ICreditCardMultisigWallet> => {
169
+ return this.http.post('/wallet/ccwallet', params)
170
+ }
171
+
172
+ executePosTransaction = (params: {
173
+ destination: string
174
+ panHash: string
175
+ amount: string
176
+ remark?: string
177
+ merchant: string
178
+ confirmations?: number
179
+ }): Promise<ITransaction> => {
180
+ return this.http.post('/wallet/tx/pos', params)
181
+ }
182
+
183
+ getTokenInfo = async (tokenAddress: string): Promise<ITokenInfo | null> => {
184
+ return this.http.get(`/wallet/blockchain/${tokenAddress}/token-info`)
185
+ }
186
+
187
+ getFeatureFlags = async (): Promise<FeatureFlags> => {
188
+ // TOOD: remove mock
189
+ return {
190
+ multisignatureWallet: true,
191
+ paymentWallet: true,
192
+ }
193
+ }
194
+ }
package/src/index.ts ADDED
@@ -0,0 +1,29 @@
1
+ export { Balance, BalanceResponse, TokenPrice } from './models/Balance'
2
+ export { BinInfo } from './models/IBinInfo'
3
+ export {
4
+ IBaseMultisigWallet,
5
+ ICreditCardMultisigWallet,
6
+ IGeneralMultisigWallet,
7
+ IMultisigWallet,
8
+ ISigner
9
+ } from './models/IMultisigWallet'
10
+ export { ITokenInfo } from './models/ITokenInfo'
11
+ export {
12
+ AssetType,
13
+ FeeQuote,
14
+ ISignature,
15
+ TransactionAsset,
16
+ ITransaction
17
+ } from './models/ITransaction'
18
+ export { IUser } from './models/IUser'
19
+ export { SimpleMultisigTransactionData } from './models/SimpleMultisigTransactionData'
20
+ export {
21
+ ERC20Transaction,
22
+ NativeTransaction,
23
+ Transaction
24
+ } from './models/Transaction'
25
+ export { Account, HDWallet } from './models/Wallet'
26
+
27
+ export { DoraApiClient } from './data/DoraApiClient'
28
+ export { MerapiClient } from './data/MerapiClient'
29
+ export { FeatureFlags } from './models/FeatureFlags'