@avacuscc/sdk 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -72,9 +72,29 @@ const client = new AvacusClient();
72
72
  const result = await client.sns.login({
73
73
  walletAddress,
74
74
  signMessage,
75
+ serviceName: 'connect', // optional: 'connect' | 'redirect' | 'gas-sponsor'
75
76
  });
77
+
78
+ `client.sns.login()` now uses `POST /v2/public/users/request_auth_token` and,
79
+ when `serviceName` is provided, builds the signed message with the matching base
80
+ message:
81
+
82
+ - omitted `serviceName`: Avacus Wallet message (`DEFAULT_BASE_SIGNED_MESSAGE`)
83
+ - `connect`: `BASE_CONNECT_SIGNED_MSG`
84
+ - `redirect`: `BASE_REDIRECT_SIGNED_MSG`
85
+ - `gas-sponsor`: `BASE_GAS_SPONSOR_SIGNED_MSG`
76
86
  ```
77
87
 
88
+ ## Services
89
+
90
+ `AvacusClient` exposes these service clients:
91
+
92
+ - `client.sns`
93
+ - `client.gasAccount`
94
+ - `client.balancer`
95
+
96
+ Most `gasAccount` APIs require a JWT token from `client.sns.login()` first.
97
+
78
98
  ### SNS create user
79
99
 
80
100
  ```ts
@@ -118,6 +138,253 @@ const profiles = await client.sns.getPublicProfiles({
118
138
  });
119
139
  ```
120
140
 
141
+ ## Gas Account service
142
+
143
+ ### Gas Account login prerequisite
144
+
145
+ Authenticated gas-account APIs require SNS login first:
146
+
147
+ ```ts
148
+ await client.sns.login({
149
+ walletAddress,
150
+ signMessage,
151
+ });
152
+ ```
153
+
154
+ ### Gas Account summary
155
+
156
+ ```ts
157
+ const summary = await client.gasAccount.getSummary();
158
+ ```
159
+
160
+ ### Gas Account stable tokens
161
+
162
+ ```ts
163
+ const tokens = await client.gasAccount.getStableTokens();
164
+ const bscTestnetTokens = await client.gasAccount.getStableTokens(97);
165
+ ```
166
+
167
+ ### Gas Account deposit vaults
168
+
169
+ ```ts
170
+ const vaults = await client.gasAccount.getDepositVaults();
171
+ ```
172
+
173
+ ### Gas Account whitelist spenders
174
+
175
+ Get current whitelist and nonce:
176
+
177
+ ```ts
178
+ const whitelist = await client.gasAccount.getWhitelistSpenders();
179
+ ```
180
+
181
+ Recommended helper for register flow:
182
+
183
+ ```ts
184
+ await client.gasAccount.registerWhitelistSpendersWithEthers({
185
+ owner: wallet.address,
186
+ spenders: [
187
+ {
188
+ address: '0x9876543210987654321098765432109876543210',
189
+ expiresAt: 0,
190
+ },
191
+ ],
192
+ signer: wallet,
193
+ });
194
+ ```
195
+
196
+ Generic signer helper when you do not want to couple app code to `ethers`:
197
+
198
+ ```ts
199
+ await client.gasAccount.registerWhitelistSpendersWithSignature({
200
+ owner: wallet.address,
201
+ spenders: [
202
+ {
203
+ address: '0x9876543210987654321098765432109876543210',
204
+ expiresAt: 0,
205
+ },
206
+ ],
207
+ signTypedData: (typedData) =>
208
+ wallet.signTypedData(
209
+ typedData.domain,
210
+ typedData.types,
211
+ typedData.message,
212
+ ),
213
+ });
214
+ ```
215
+
216
+ Low-level flow when you want full control:
217
+
218
+ ```ts
219
+ const { data } = await client.gasAccount.getWhitelistSpenders();
220
+
221
+ const typedData = client.gasAccount.buildRegisterWhitelistSpendersTypedData({
222
+ owner: wallet.address,
223
+ spenders: [
224
+ {
225
+ address: '0x9876543210987654321098765432109876543210',
226
+ expiresAt: 0,
227
+ },
228
+ ],
229
+ nonce: data.nonce,
230
+ deadline: Math.floor(Date.now() / 1000) + 600,
231
+ });
232
+
233
+ const signature = await wallet.signTypedData(
234
+ typedData.domain,
235
+ typedData.types,
236
+ typedData.message,
237
+ );
238
+
239
+ await client.gasAccount.registerWhitelistSpenders({
240
+ spenders: typedData.message.spenders,
241
+ nonce: typedData.message.nonce,
242
+ deadline: typedData.message.deadline,
243
+ signature,
244
+ });
245
+ ```
246
+
247
+ Remove spenders:
248
+
249
+ ```ts
250
+ await client.gasAccount.removeWhitelistSpenders({
251
+ spenders: ['0x9876543210987654321098765432109876543210'],
252
+ });
253
+ ```
254
+
255
+ ### Gas Account balances
256
+
257
+ ```ts
258
+ const balance = await client.gasAccount.getBalance();
259
+ const detailedBalance = await client.gasAccount.getDetailedBalance();
260
+ const stats = await client.gasAccount.getBalanceStats();
261
+ ```
262
+
263
+ Public batch balances:
264
+
265
+ ```ts
266
+ const balances = await client.gasAccount.getBalances({
267
+ addresses: [
268
+ '0x3a0430580303f4De9C5320aC013f14cd92192bfA',
269
+ '0x610b463d2f57d2e0d9e785a7ff423fbae36f0624',
270
+ ],
271
+ });
272
+ ```
273
+
274
+ ### Gas Account transactions
275
+
276
+ List transactions:
277
+
278
+ ```ts
279
+ const transactions = await client.gasAccount.listTransactions({
280
+ page: 1,
281
+ per: 10,
282
+ type: 'DEPOSIT',
283
+ status: 'CONFIRMED',
284
+ });
285
+ ```
286
+
287
+ Get transaction by ID:
288
+
289
+ ```ts
290
+ const transaction = await client.gasAccount.getTransactionById(transactionId);
291
+ ```
292
+
293
+ Create deposit:
294
+
295
+ ```ts
296
+ await client.gasAccount.createDeposit({
297
+ chainId: 97,
298
+ amount: '100.00000000',
299
+ tokenAddress: '0x5bF5121A17e3329D07Ba43f758dEC271D9105132',
300
+ txHash: '0xe3844e7bc420b2d409058e6bf5534fdba69b917907d691abf65862654df749d7',
301
+ actor: walletAddress,
302
+ notes: 'Deposit from wallet',
303
+ });
304
+ ```
305
+
306
+ Use balance for gas:
307
+
308
+ ```ts
309
+ await client.gasAccount.useBalance({
310
+ toAddress: '0x9876543210987654321098765432109876543210',
311
+ chainId: 97,
312
+ gasLimit: 21000,
313
+ gasPrice: 5,
314
+ notes: 'Gas for token transfer',
315
+ });
316
+ ```
317
+
318
+ Use balance from another owner's gas account via delegated spender permission:
319
+
320
+ ```ts
321
+ await client.gasAccount.useBalance({
322
+ toAddress: '0x9876543210987654321098765432109876543210',
323
+ chainId: 97,
324
+ gasLimit: 21000,
325
+ gasPrice: 5,
326
+ sourceAddress: '0x610b463d2f57d2e0d9e785a7ff423fbae36f0624',
327
+ notes: 'Use gas from delegated source account',
328
+ });
329
+ ```
330
+
331
+ `sourceAddress` is important for delegated spending flows:
332
+
333
+ - omit `sourceAddress` to spend from the currently authenticated user's own gas account
334
+ - provide `sourceAddress` to spend from another owner's gas account
335
+ - to make that possible, the owner must first authorize the caller with `registerWhitelistSpenders(...)` or one of the helper methods
336
+ - the logged-in user must already be whitelisted as a spender for that `sourceAddress`
337
+ - when `sourceAddress` is used, the returned balance payload reflects the source owner's balance
338
+
339
+ Create sponsored transfer:
340
+
341
+ ```ts
342
+ await client.gasAccount.createSponsoredTransfer({
343
+ transactions: [
344
+ {
345
+ tokenAddress: '0x409E7b65eF7B243529e3F97be2A122123c55DE63',
346
+ from: '0x1234567890123456789012345678901234567890',
347
+ to: '0x9876543210987654321098765432109876543210',
348
+ value: '1000000000000000000',
349
+ validBefore: 1735689600,
350
+ validAfter: 0,
351
+ nonce: '0x0000000000000000000000000000000000000000000000000000000000000001',
352
+ signature: '0x...',
353
+ },
354
+ ],
355
+ chainId: 97,
356
+ type: 'ADMIN',
357
+ notes: 'JPYC transfer sponsorship',
358
+ });
359
+ ```
360
+
361
+ Cancel pending transaction:
362
+
363
+ ```ts
364
+ await client.gasAccount.cancelTransaction(transactionId);
365
+ ```
366
+
367
+ Internal funding request:
368
+
369
+ ```ts
370
+ await client.gasAccount.createFundingRequest({
371
+ sourceAddress: '0x610b463d2f57d2e0d9e785a7ff423fbae36f0624',
372
+ toAddress: '0x9876543210987654321098765432109876543210',
373
+ chainId: 97,
374
+ gasLimit: 21000,
375
+ gasPrice: 5,
376
+ notes: 'Gas for token transfer',
377
+ });
378
+ ```
379
+
380
+ ## Balancer service
381
+
382
+ ### Get balancer pools
383
+
384
+ ```ts
385
+ const pools = await client.balancer.getPools();
386
+ ```
387
+
121
388
  ### SNS-only import
122
389
 
123
390
  ```ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@avacuscc/sdk",
3
- "version": "0.1.0",
4
- "description": "SDK for interacting with services in the Wakumo ecosystem",
3
+ "version": "0.2.1",
4
+ "description": "SDK for interacting with Avacuscc services",
5
5
  "main": "./packages/sdk/dist/index.js",
6
6
  "module": "./packages/sdk/dist/index.mjs",
7
7
  "types": "./packages/sdk/dist/index.d.ts",
@@ -22,8 +22,8 @@
22
22
  "README.md"
23
23
  ],
24
24
  "scripts": {
25
- "build": "tsup packages/sdk/src/index.ts packages/sdk/src/sns.ts --format cjs,esm --dts --clean --out-dir packages/sdk/dist",
26
- "dev": "tsup packages/sdk/src/index.ts packages/sdk/src/sns.ts --format cjs,esm --dts --watch --out-dir packages/sdk/dist",
25
+ "build": "tsup",
26
+ "dev": "tsup --watch",
27
27
  "test": "echo \"Error: no test specified\" && exit 1"
28
28
  },
29
29
  "keywords": [],