@chipi-stack/backend 0.1.0 → 0.2.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.
- package/dist/client-BaNfges3.d.mts +39 -0
- package/dist/client-BaNfges3.d.ts +39 -0
- package/dist/index.d.mts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +124 -190
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -191
- package/dist/index.mjs.map +1 -1
- package/dist/skus.d.mts +2 -41
- package/dist/skus.d.ts +2 -41
- package/dist/skus.js +0 -75
- package/dist/skus.js.map +1 -1
- package/dist/skus.mjs +0 -75
- package/dist/skus.mjs.map +1 -1
- package/dist/transactions.d.mts +11 -9
- package/dist/transactions.d.ts +11 -9
- package/dist/transactions.js +36 -7
- package/dist/transactions.js.map +1 -1
- package/dist/transactions.mjs +37 -8
- package/dist/transactions.mjs.map +1 -1
- package/dist/wallets.d.mts +7 -15
- package/dist/wallets.d.ts +7 -15
- package/dist/wallets.js +32 -65
- package/dist/wallets.js.map +1 -1
- package/dist/wallets.mjs +33 -66
- package/dist/wallets.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/client-3HAMR0rB.d.mts +0 -24
- package/dist/client-3HAMR0rB.d.ts +0 -24
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChipiSDKConfig } from '@chipi-stack/types';
|
|
2
|
+
import { ApiResponse } from '@chipi-stack/shared';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HTTP client for Chipi API interactions
|
|
6
|
+
*/
|
|
7
|
+
declare class ChipiClient {
|
|
8
|
+
private apiPublicKey;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
private environment;
|
|
11
|
+
constructor(config: ChipiSDKConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Get the API public key (for internal SDK use)
|
|
14
|
+
*/
|
|
15
|
+
getApiPublicKey(): string;
|
|
16
|
+
private getBaseUrl;
|
|
17
|
+
private getHeaders;
|
|
18
|
+
get<T>({ endpoint, params, bearerToken, }: {
|
|
19
|
+
endpoint: string;
|
|
20
|
+
params?: Record<string, any>;
|
|
21
|
+
bearerToken?: string;
|
|
22
|
+
}): Promise<ApiResponse<T>>;
|
|
23
|
+
post<T>({ endpoint, bearerToken, body, }: {
|
|
24
|
+
endpoint: string;
|
|
25
|
+
bearerToken: string;
|
|
26
|
+
body?: Record<string, any>;
|
|
27
|
+
}): Promise<ApiResponse<T>>;
|
|
28
|
+
put<T>({ endpoint, bearerToken, body, }: {
|
|
29
|
+
endpoint: string;
|
|
30
|
+
bearerToken: string;
|
|
31
|
+
body?: Record<string, any>;
|
|
32
|
+
}): Promise<ApiResponse<T>>;
|
|
33
|
+
delete<T>({ endpoint, bearerToken, }: {
|
|
34
|
+
endpoint: string;
|
|
35
|
+
bearerToken: string;
|
|
36
|
+
}): Promise<ApiResponse<T>>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { ChipiClient as C };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ChipiSDKConfig } from '@chipi-stack/types';
|
|
2
|
+
import { ApiResponse } from '@chipi-stack/shared';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HTTP client for Chipi API interactions
|
|
6
|
+
*/
|
|
7
|
+
declare class ChipiClient {
|
|
8
|
+
private apiPublicKey;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
private environment;
|
|
11
|
+
constructor(config: ChipiSDKConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Get the API public key (for internal SDK use)
|
|
14
|
+
*/
|
|
15
|
+
getApiPublicKey(): string;
|
|
16
|
+
private getBaseUrl;
|
|
17
|
+
private getHeaders;
|
|
18
|
+
get<T>({ endpoint, params, bearerToken, }: {
|
|
19
|
+
endpoint: string;
|
|
20
|
+
params?: Record<string, any>;
|
|
21
|
+
bearerToken?: string;
|
|
22
|
+
}): Promise<ApiResponse<T>>;
|
|
23
|
+
post<T>({ endpoint, bearerToken, body, }: {
|
|
24
|
+
endpoint: string;
|
|
25
|
+
bearerToken: string;
|
|
26
|
+
body?: Record<string, any>;
|
|
27
|
+
}): Promise<ApiResponse<T>>;
|
|
28
|
+
put<T>({ endpoint, bearerToken, body, }: {
|
|
29
|
+
endpoint: string;
|
|
30
|
+
bearerToken: string;
|
|
31
|
+
body?: Record<string, any>;
|
|
32
|
+
}): Promise<ApiResponse<T>>;
|
|
33
|
+
delete<T>({ endpoint, bearerToken, }: {
|
|
34
|
+
endpoint: string;
|
|
35
|
+
bearerToken: string;
|
|
36
|
+
}): Promise<ApiResponse<T>>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { ChipiClient as C };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse } from '@chipi-stack/types';
|
|
1
|
+
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
|
|
2
2
|
export * from '@chipi-stack/types';
|
|
3
3
|
import { ChipiWallets } from './wallets.mjs';
|
|
4
4
|
import { ChipiTransactions } from './transactions.mjs';
|
|
5
5
|
import { ChipiSkus } from './skus.mjs';
|
|
6
|
-
export { C as ChipiClient } from './client-
|
|
6
|
+
export { C as ChipiClient } from './client-BaNfges3.mjs';
|
|
7
7
|
import '@chipi-stack/shared';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -19,31 +19,41 @@ declare class ChipiSDK {
|
|
|
19
19
|
/**
|
|
20
20
|
* Execute a gasless transaction
|
|
21
21
|
*/
|
|
22
|
-
executeTransaction(input: Omit<ExecuteTransactionParams,
|
|
22
|
+
executeTransaction(input: Omit<ExecuteTransactionParams, "apiPublicKey">): Promise<string>;
|
|
23
23
|
/**
|
|
24
24
|
* Transfer tokens
|
|
25
25
|
*/
|
|
26
|
-
transfer(params
|
|
26
|
+
transfer({ params, bearerToken, }: {
|
|
27
|
+
params: TransferParams;
|
|
28
|
+
bearerToken: string;
|
|
29
|
+
}): Promise<string>;
|
|
27
30
|
/**
|
|
28
31
|
* Approve token spending
|
|
29
32
|
*/
|
|
30
|
-
approve(params: Omit<ApproveParams,
|
|
33
|
+
approve(params: Omit<ApproveParams, "apiPublicKey">): Promise<string>;
|
|
31
34
|
/**
|
|
32
35
|
* Stake USDC in Vesu protocol
|
|
33
36
|
*/
|
|
34
|
-
stakeVesuUsdc(params: Omit<StakeVesuUsdcParams,
|
|
37
|
+
stakeVesuUsdc(params: Omit<StakeVesuUsdcParams, "apiPublicKey">): Promise<string>;
|
|
35
38
|
/**
|
|
36
39
|
* Withdraw USDC from Vesu protocol
|
|
37
40
|
*/
|
|
38
|
-
withdrawVesuUsdc(params: Omit<WithdrawVesuUsdcParams,
|
|
41
|
+
withdrawVesuUsdc(params: Omit<WithdrawVesuUsdcParams, "apiPublicKey">): Promise<string>;
|
|
39
42
|
/**
|
|
40
43
|
* Call any contract method
|
|
41
44
|
*/
|
|
42
|
-
callAnyContract(params: Omit<CallAnyContractParams,
|
|
45
|
+
callAnyContract(params: Omit<CallAnyContractParams, "apiPublicKey">): Promise<string>;
|
|
43
46
|
/**
|
|
44
47
|
* Create a new wallet
|
|
45
48
|
*/
|
|
46
|
-
createWallet(params
|
|
49
|
+
createWallet({ params, bearerToken, }: {
|
|
50
|
+
params: CreateWalletParams;
|
|
51
|
+
bearerToken: string;
|
|
52
|
+
}): Promise<CreateWalletResponse>;
|
|
53
|
+
recordSendTransaction({ params, bearerToken, }: {
|
|
54
|
+
params: RecordSendTransactionParams;
|
|
55
|
+
bearerToken: string;
|
|
56
|
+
}): Promise<Transaction>;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
declare const encryptPrivateKey: (privateKey: string, password: string) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse } from '@chipi-stack/types';
|
|
1
|
+
import { ChipiSDKConfig, ExecuteTransactionParams, TransferParams, ApproveParams, StakeVesuUsdcParams, WithdrawVesuUsdcParams, CallAnyContractParams, CreateWalletParams, CreateWalletResponse, RecordSendTransactionParams, Transaction } from '@chipi-stack/types';
|
|
2
2
|
export * from '@chipi-stack/types';
|
|
3
3
|
import { ChipiWallets } from './wallets.js';
|
|
4
4
|
import { ChipiTransactions } from './transactions.js';
|
|
5
5
|
import { ChipiSkus } from './skus.js';
|
|
6
|
-
export { C as ChipiClient } from './client-
|
|
6
|
+
export { C as ChipiClient } from './client-BaNfges3.js';
|
|
7
7
|
import '@chipi-stack/shared';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -19,31 +19,41 @@ declare class ChipiSDK {
|
|
|
19
19
|
/**
|
|
20
20
|
* Execute a gasless transaction
|
|
21
21
|
*/
|
|
22
|
-
executeTransaction(input: Omit<ExecuteTransactionParams,
|
|
22
|
+
executeTransaction(input: Omit<ExecuteTransactionParams, "apiPublicKey">): Promise<string>;
|
|
23
23
|
/**
|
|
24
24
|
* Transfer tokens
|
|
25
25
|
*/
|
|
26
|
-
transfer(params
|
|
26
|
+
transfer({ params, bearerToken, }: {
|
|
27
|
+
params: TransferParams;
|
|
28
|
+
bearerToken: string;
|
|
29
|
+
}): Promise<string>;
|
|
27
30
|
/**
|
|
28
31
|
* Approve token spending
|
|
29
32
|
*/
|
|
30
|
-
approve(params: Omit<ApproveParams,
|
|
33
|
+
approve(params: Omit<ApproveParams, "apiPublicKey">): Promise<string>;
|
|
31
34
|
/**
|
|
32
35
|
* Stake USDC in Vesu protocol
|
|
33
36
|
*/
|
|
34
|
-
stakeVesuUsdc(params: Omit<StakeVesuUsdcParams,
|
|
37
|
+
stakeVesuUsdc(params: Omit<StakeVesuUsdcParams, "apiPublicKey">): Promise<string>;
|
|
35
38
|
/**
|
|
36
39
|
* Withdraw USDC from Vesu protocol
|
|
37
40
|
*/
|
|
38
|
-
withdrawVesuUsdc(params: Omit<WithdrawVesuUsdcParams,
|
|
41
|
+
withdrawVesuUsdc(params: Omit<WithdrawVesuUsdcParams, "apiPublicKey">): Promise<string>;
|
|
39
42
|
/**
|
|
40
43
|
* Call any contract method
|
|
41
44
|
*/
|
|
42
|
-
callAnyContract(params: Omit<CallAnyContractParams,
|
|
45
|
+
callAnyContract(params: Omit<CallAnyContractParams, "apiPublicKey">): Promise<string>;
|
|
43
46
|
/**
|
|
44
47
|
* Create a new wallet
|
|
45
48
|
*/
|
|
46
|
-
createWallet(params
|
|
49
|
+
createWallet({ params, bearerToken, }: {
|
|
50
|
+
params: CreateWalletParams;
|
|
51
|
+
bearerToken: string;
|
|
52
|
+
}): Promise<CreateWalletResponse>;
|
|
53
|
+
recordSendTransaction({ params, bearerToken, }: {
|
|
54
|
+
params: RecordSendTransactionParams;
|
|
55
|
+
bearerToken: string;
|
|
56
|
+
}): Promise<Transaction>;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
declare const encryptPrivateKey: (privateKey: string, password: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var shared = require('@chipi-stack/shared');
|
|
4
4
|
var starknet = require('starknet');
|
|
5
5
|
var CryptoJS2 = require('crypto-js');
|
|
6
|
+
var types = require('@chipi-stack/types');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -40,7 +41,11 @@ var ChipiClient = class {
|
|
|
40
41
|
}
|
|
41
42
|
return headers;
|
|
42
43
|
}
|
|
43
|
-
async get(
|
|
44
|
+
async get({
|
|
45
|
+
endpoint,
|
|
46
|
+
params,
|
|
47
|
+
bearerToken
|
|
48
|
+
}) {
|
|
44
49
|
try {
|
|
45
50
|
const url = new URL(`${this.baseUrl}${endpoint}`);
|
|
46
51
|
if (params) {
|
|
@@ -71,7 +76,11 @@ var ChipiClient = class {
|
|
|
71
76
|
throw shared.handleApiError(error);
|
|
72
77
|
}
|
|
73
78
|
}
|
|
74
|
-
async post(
|
|
79
|
+
async post({
|
|
80
|
+
endpoint,
|
|
81
|
+
bearerToken,
|
|
82
|
+
body
|
|
83
|
+
}) {
|
|
75
84
|
try {
|
|
76
85
|
const response = await fetch(`${this.baseUrl}${endpoint}`, {
|
|
77
86
|
method: "POST",
|
|
@@ -95,7 +104,11 @@ var ChipiClient = class {
|
|
|
95
104
|
throw shared.handleApiError(error);
|
|
96
105
|
}
|
|
97
106
|
}
|
|
98
|
-
async put(
|
|
107
|
+
async put({
|
|
108
|
+
endpoint,
|
|
109
|
+
bearerToken,
|
|
110
|
+
body
|
|
111
|
+
}) {
|
|
99
112
|
try {
|
|
100
113
|
const response = await fetch(`${this.baseUrl}${endpoint}`, {
|
|
101
114
|
method: "PUT",
|
|
@@ -119,7 +132,10 @@ var ChipiClient = class {
|
|
|
119
132
|
throw shared.handleApiError(error);
|
|
120
133
|
}
|
|
121
134
|
}
|
|
122
|
-
async delete(
|
|
135
|
+
async delete({
|
|
136
|
+
endpoint,
|
|
137
|
+
bearerToken
|
|
138
|
+
}) {
|
|
123
139
|
try {
|
|
124
140
|
const response = await fetch(`${this.baseUrl}${endpoint}`, {
|
|
125
141
|
method: "DELETE",
|
|
@@ -184,7 +200,7 @@ var ChipiWallets = class {
|
|
|
184
200
|
// }
|
|
185
201
|
async createWallet(params) {
|
|
186
202
|
try {
|
|
187
|
-
const { encryptKey,
|
|
203
|
+
const { encryptKey, nodeUrl, externalUserId, bearerToken } = params;
|
|
188
204
|
const provider = new starknet.RpcProvider({ nodeUrl });
|
|
189
205
|
const privateKeyAX = starknet.stark.randomAddress();
|
|
190
206
|
const starkKeyPubAX = starknet.ec.starkCurve.getStarkKey(privateKeyAX);
|
|
@@ -204,19 +220,14 @@ var ChipiWallets = class {
|
|
|
204
220
|
0
|
|
205
221
|
);
|
|
206
222
|
const account = new starknet.Account(provider, publicKey, privateKeyAX);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
"Content-Type": "application/json",
|
|
212
|
-
"Authorization": `Bearer ${bearerToken}`,
|
|
213
|
-
"x-api-key": apiPublicKey
|
|
214
|
-
},
|
|
215
|
-
body: JSON.stringify({
|
|
223
|
+
const typeDataResponse = await this.client.post({
|
|
224
|
+
endpoint: `${shared.API_ENDPOINTS.CHIPI_WALLETS}/prepare-creation`,
|
|
225
|
+
bearerToken,
|
|
226
|
+
body: {
|
|
216
227
|
publicKey
|
|
217
|
-
}
|
|
228
|
+
}
|
|
218
229
|
});
|
|
219
|
-
const { typeData, accountClassHash: accountClassHashResponse } =
|
|
230
|
+
const { typeData, accountClassHash: accountClassHashResponse } = typeDataResponse.data;
|
|
220
231
|
const userSignature = await account.signMessage(typeData);
|
|
221
232
|
const deploymentData = {
|
|
222
233
|
class_hash: accountClassHashResponse,
|
|
@@ -224,16 +235,15 @@ var ChipiWallets = class {
|
|
|
224
235
|
unique: `${starknet.num.toHex(0)}`,
|
|
225
236
|
calldata: AXConstructorCallData.map((value) => starknet.num.toHex(value))
|
|
226
237
|
};
|
|
227
|
-
const encryptedPrivateKey = this.encryptPrivateKey(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
apiPublicKey,
|
|
238
|
+
const encryptedPrivateKey = this.encryptPrivateKey(
|
|
239
|
+
privateKeyAX,
|
|
240
|
+
encryptKey
|
|
241
|
+
);
|
|
242
|
+
const executeTransactionResponse = await this.client.post({
|
|
243
|
+
endpoint: `${shared.API_ENDPOINTS.CHIPI_WALLETS}`,
|
|
244
|
+
bearerToken,
|
|
245
|
+
body: {
|
|
246
|
+
externalUserId,
|
|
237
247
|
publicKey,
|
|
238
248
|
userSignature: {
|
|
239
249
|
r: userSignature.r.toString(),
|
|
@@ -247,9 +257,9 @@ var ChipiWallets = class {
|
|
|
247
257
|
salt: `${deploymentData.salt}`,
|
|
248
258
|
calldata: deploymentData.calldata.map((data) => `${data}`)
|
|
249
259
|
}
|
|
250
|
-
}
|
|
260
|
+
}
|
|
251
261
|
});
|
|
252
|
-
const executeTransaction =
|
|
262
|
+
const executeTransaction = executeTransactionResponse.data;
|
|
253
263
|
if (executeTransaction.success) {
|
|
254
264
|
return {
|
|
255
265
|
success: true,
|
|
@@ -258,21 +268,16 @@ var ChipiWallets = class {
|
|
|
258
268
|
wallet: executeTransaction.wallet
|
|
259
269
|
};
|
|
260
270
|
} else {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
wallet: {
|
|
266
|
-
publicKey: "",
|
|
267
|
-
encryptedPrivateKey: ""
|
|
268
|
-
}
|
|
269
|
-
};
|
|
271
|
+
throw new shared.ChipiTransactionError(
|
|
272
|
+
`Failed to create wallet: ${executeTransaction.message}`,
|
|
273
|
+
"WALLET_CREATION_FAILED"
|
|
274
|
+
);
|
|
270
275
|
}
|
|
271
276
|
} catch (error) {
|
|
272
277
|
console.error("Error detallado:", error);
|
|
273
278
|
if (error instanceof Error && error.message.includes("SSL")) {
|
|
274
279
|
throw new Error(
|
|
275
|
-
"
|
|
280
|
+
"SSL connection error. Try using NODE_TLS_REJECT_UNAUTHORIZED=0 or verify the RPC URL"
|
|
276
281
|
);
|
|
277
282
|
}
|
|
278
283
|
throw new shared.ChipiTransactionError(
|
|
@@ -284,37 +289,15 @@ var ChipiWallets = class {
|
|
|
284
289
|
/**
|
|
285
290
|
* Create a custodial merchant wallet
|
|
286
291
|
*/
|
|
287
|
-
async createCustodialWallet(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Get merchant wallet by API key and chain
|
|
299
|
-
*/
|
|
300
|
-
async getMerchantWallet(params) {
|
|
301
|
-
const response = await this.client.get(
|
|
302
|
-
`${shared.API_ENDPOINTS.CHIPI_WALLETS}/merchant`,
|
|
303
|
-
{
|
|
304
|
-
apiKeyId: params.apiKeyId,
|
|
305
|
-
chain: params.chain
|
|
306
|
-
}
|
|
307
|
-
);
|
|
308
|
-
return response.data;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Get wallets for an organization
|
|
312
|
-
*/
|
|
313
|
-
async getWallets(query) {
|
|
314
|
-
const response = await this.client.get(
|
|
315
|
-
shared.API_ENDPOINTS.CHIPI_WALLETS,
|
|
316
|
-
query
|
|
317
|
-
);
|
|
292
|
+
async createCustodialWallet({
|
|
293
|
+
params,
|
|
294
|
+
bearerToken
|
|
295
|
+
}) {
|
|
296
|
+
const response = await this.client.post({
|
|
297
|
+
endpoint: `${shared.API_ENDPOINTS.CHIPI_WALLETS}/custodial`,
|
|
298
|
+
bearerToken,
|
|
299
|
+
body: params
|
|
300
|
+
});
|
|
318
301
|
return response.data;
|
|
319
302
|
}
|
|
320
303
|
};
|
|
@@ -430,18 +413,32 @@ var ChipiTransactions = class {
|
|
|
430
413
|
/**
|
|
431
414
|
* Transfer tokens
|
|
432
415
|
*/
|
|
433
|
-
async transfer(
|
|
434
|
-
|
|
416
|
+
async transfer({
|
|
417
|
+
params,
|
|
418
|
+
bearerToken
|
|
419
|
+
}) {
|
|
420
|
+
const { encryptKey, wallet, token, otherToken, recipient, amount } = params;
|
|
421
|
+
const contract = types.STARKNET_CONTRACTS[token];
|
|
422
|
+
let contractAddress = contract.contractAddress;
|
|
423
|
+
let decimals = contract.decimals;
|
|
424
|
+
if (token === "OTHER") {
|
|
425
|
+
if (!otherToken) {
|
|
426
|
+
throw new Error("Other token is required when token is OTHER");
|
|
427
|
+
}
|
|
428
|
+
contractAddress = otherToken.contractAddress;
|
|
429
|
+
decimals = otherToken.decimals;
|
|
430
|
+
}
|
|
431
|
+
const formattedAmount = shared.formatAmount(amount, decimals);
|
|
435
432
|
return this.executeTransaction({
|
|
436
|
-
encryptKey
|
|
437
|
-
wallet
|
|
438
|
-
bearerToken
|
|
433
|
+
encryptKey,
|
|
434
|
+
wallet,
|
|
435
|
+
bearerToken,
|
|
439
436
|
calls: [
|
|
440
437
|
{
|
|
441
|
-
contractAddress
|
|
438
|
+
contractAddress,
|
|
442
439
|
entrypoint: "transfer",
|
|
443
440
|
calldata: [
|
|
444
|
-
|
|
441
|
+
recipient,
|
|
445
442
|
formattedAmount,
|
|
446
443
|
"0x0"
|
|
447
444
|
]
|
|
@@ -482,83 +479,26 @@ var ChipiTransactions = class {
|
|
|
482
479
|
calls: params.calls
|
|
483
480
|
});
|
|
484
481
|
}
|
|
485
|
-
};
|
|
486
|
-
var ChipiSkus = class {
|
|
487
|
-
constructor(client) {
|
|
488
|
-
this.client = client;
|
|
489
|
-
}
|
|
490
482
|
/**
|
|
491
|
-
*
|
|
483
|
+
* Record a send transaction
|
|
492
484
|
*/
|
|
493
|
-
async
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Get SKU by ID
|
|
504
|
-
*/
|
|
505
|
-
async getSku(skuId) {
|
|
506
|
-
const response = await this.client.get(
|
|
507
|
-
`${shared.API_ENDPOINTS.SKUS}/${skuId}`
|
|
508
|
-
);
|
|
509
|
-
return response.data;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Create a SKU transaction
|
|
513
|
-
*/
|
|
514
|
-
async createSkuTransaction(params) {
|
|
515
|
-
const response = await this.client.post(
|
|
516
|
-
shared.API_ENDPOINTS.SKU_TRANSACTIONS,
|
|
517
|
-
params
|
|
518
|
-
);
|
|
519
|
-
return response.data;
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Get SKU transaction by ID
|
|
523
|
-
*/
|
|
524
|
-
async getSkuTransaction(transactionId) {
|
|
525
|
-
const response = await this.client.get(
|
|
526
|
-
`${shared.API_ENDPOINTS.SKU_TRANSACTIONS}/${transactionId}`
|
|
527
|
-
);
|
|
528
|
-
return response.data;
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Get SKU transactions for a wallet
|
|
532
|
-
*/
|
|
533
|
-
async getSkuTransactionsByWallet(walletAddress, params = {}) {
|
|
534
|
-
const response = await this.client.get(
|
|
535
|
-
shared.API_ENDPOINTS.SKU_TRANSACTIONS,
|
|
536
|
-
{
|
|
537
|
-
walletAddress,
|
|
538
|
-
...params
|
|
539
|
-
}
|
|
540
|
-
);
|
|
485
|
+
async recordSendTransaction({
|
|
486
|
+
params,
|
|
487
|
+
bearerToken
|
|
488
|
+
}) {
|
|
489
|
+
const response = await this.client.post({
|
|
490
|
+
endpoint: `${shared.API_ENDPOINTS.TRANSACTIONS}/record-send`,
|
|
491
|
+
bearerToken,
|
|
492
|
+
body: params
|
|
493
|
+
});
|
|
541
494
|
return response.data;
|
|
542
495
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const transaction = await this.createSkuTransaction({
|
|
550
|
-
walletAddress: params.walletAddress,
|
|
551
|
-
skuId: params.skuId,
|
|
552
|
-
chain: params.chain,
|
|
553
|
-
chainToken: params.chainToken,
|
|
554
|
-
mxnAmount: params.mxnAmount,
|
|
555
|
-
reference: params.reference,
|
|
556
|
-
transactionHash: params.transactionHash
|
|
557
|
-
});
|
|
558
|
-
return {
|
|
559
|
-
sku,
|
|
560
|
-
transaction
|
|
561
|
-
};
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// src/skus.ts
|
|
499
|
+
var ChipiSkus = class {
|
|
500
|
+
constructor(client) {
|
|
501
|
+
this.client = client;
|
|
562
502
|
}
|
|
563
503
|
};
|
|
564
504
|
|
|
@@ -577,6 +517,7 @@ var ChipiSDK = class {
|
|
|
577
517
|
this.withdrawVesuUsdc = this.withdrawVesuUsdc.bind(this);
|
|
578
518
|
this.callAnyContract = this.callAnyContract.bind(this);
|
|
579
519
|
this.createWallet = this.createWallet.bind(this);
|
|
520
|
+
this.recordSendTransaction = this.recordSendTransaction.bind(this);
|
|
580
521
|
}
|
|
581
522
|
/**
|
|
582
523
|
* Execute a gasless transaction
|
|
@@ -587,31 +528,28 @@ var ChipiSDK = class {
|
|
|
587
528
|
/**
|
|
588
529
|
* Transfer tokens
|
|
589
530
|
*/
|
|
590
|
-
async transfer(
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
bearerToken
|
|
597
|
-
calls: [
|
|
598
|
-
{
|
|
599
|
-
contractAddress,
|
|
600
|
-
entrypoint: "transfer",
|
|
601
|
-
calldata: [
|
|
602
|
-
recipient,
|
|
603
|
-
formattedAmount,
|
|
604
|
-
"0x0"
|
|
605
|
-
]
|
|
606
|
-
}
|
|
607
|
-
]
|
|
531
|
+
async transfer({
|
|
532
|
+
params,
|
|
533
|
+
bearerToken
|
|
534
|
+
}) {
|
|
535
|
+
return this.transactions.transfer({
|
|
536
|
+
params,
|
|
537
|
+
bearerToken
|
|
608
538
|
});
|
|
609
539
|
}
|
|
610
540
|
/**
|
|
611
541
|
* Approve token spending
|
|
612
542
|
*/
|
|
613
543
|
async approve(params) {
|
|
614
|
-
const {
|
|
544
|
+
const {
|
|
545
|
+
encryptKey,
|
|
546
|
+
wallet,
|
|
547
|
+
contractAddress,
|
|
548
|
+
spender,
|
|
549
|
+
amount,
|
|
550
|
+
decimals,
|
|
551
|
+
bearerToken
|
|
552
|
+
} = params;
|
|
615
553
|
return this.executeTransaction({
|
|
616
554
|
encryptKey,
|
|
617
555
|
wallet,
|
|
@@ -620,11 +558,7 @@ var ChipiSDK = class {
|
|
|
620
558
|
{
|
|
621
559
|
contractAddress,
|
|
622
560
|
entrypoint: "approve",
|
|
623
|
-
calldata: [
|
|
624
|
-
spender,
|
|
625
|
-
shared.formatAmount(amount, decimals),
|
|
626
|
-
"0x0"
|
|
627
|
-
]
|
|
561
|
+
calldata: [spender, shared.formatAmount(amount, decimals), "0x0"]
|
|
628
562
|
}
|
|
629
563
|
]
|
|
630
564
|
});
|
|
@@ -652,11 +586,7 @@ var ChipiSDK = class {
|
|
|
652
586
|
{
|
|
653
587
|
contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
|
|
654
588
|
entrypoint: "deposit",
|
|
655
|
-
calldata: [
|
|
656
|
-
formattedAmount,
|
|
657
|
-
"0x0",
|
|
658
|
-
receiverWallet
|
|
659
|
-
]
|
|
589
|
+
calldata: [formattedAmount, "0x0", receiverWallet]
|
|
660
590
|
}
|
|
661
591
|
]
|
|
662
592
|
});
|
|
@@ -675,11 +605,7 @@ var ChipiSDK = class {
|
|
|
675
605
|
{
|
|
676
606
|
contractAddress: shared.CONTRACT_ADDRESSES.VESU_USDC_MAINNET,
|
|
677
607
|
entrypoint: "withdraw",
|
|
678
|
-
calldata: [
|
|
679
|
-
formattedAmount,
|
|
680
|
-
recipient,
|
|
681
|
-
"0x0"
|
|
682
|
-
]
|
|
608
|
+
calldata: [formattedAmount, recipient, "0x0"]
|
|
683
609
|
}
|
|
684
610
|
]
|
|
685
611
|
});
|
|
@@ -699,14 +625,22 @@ var ChipiSDK = class {
|
|
|
699
625
|
/**
|
|
700
626
|
* Create a new wallet
|
|
701
627
|
*/
|
|
702
|
-
async createWallet(
|
|
703
|
-
|
|
628
|
+
async createWallet({
|
|
629
|
+
params,
|
|
630
|
+
bearerToken
|
|
631
|
+
}) {
|
|
704
632
|
return this.wallets.createWallet({
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
633
|
+
...params,
|
|
634
|
+
bearerToken
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
async recordSendTransaction({
|
|
638
|
+
params,
|
|
639
|
+
bearerToken
|
|
640
|
+
}) {
|
|
641
|
+
return this.transactions.recordSendTransaction({
|
|
642
|
+
params,
|
|
643
|
+
bearerToken
|
|
710
644
|
});
|
|
711
645
|
}
|
|
712
646
|
};
|