@superfluid-finance/sdk-core 0.1.1-dev.88df1a2.0 → 0.1.1-dev.bc1d5ba.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/README.md +378 -53
- package/dist/main/BatchCall.d.ts +1 -1
- package/dist/main/ConstantFlowAgreementV1.d.ts +2 -2
- package/dist/main/Framework.d.ts +5 -5
- package/dist/main/InstantDistributionAgreementV1.d.ts +2 -2
- package/dist/main/Query.d.ts +3 -3
- package/dist/main/SuperToken.d.ts +2 -2
- package/dist/main/Token.d.ts +1 -1
- package/dist/main/index.d.ts +5 -5
- package/dist/main/index.js +6069 -6048
- package/dist/main/interfaces.d.ts +3 -6
- package/dist/main/ordering.d.ts +1 -1
- package/dist/main/pagination.d.ts +2 -2
- package/dist/main/subgraph/queries/getAllEvents.generated.d.ts +4 -4
- package/dist/main/subgraph/schema.generated.d.ts +33 -42
- package/dist/main/typechain/IResolver.d.ts +17 -3
- package/dist/main/typechain/TestToken.d.ts +8 -0
- package/dist/main/typechain/factories/IResolver__factory.d.ts +15 -2
- package/dist/main/validation.d.ts +1 -1
- package/dist/module/BatchCall.d.ts +1 -1
- package/dist/module/ConstantFlowAgreementV1.d.ts +2 -2
- package/dist/module/Framework.d.ts +5 -5
- package/dist/module/InstantDistributionAgreementV1.d.ts +2 -2
- package/dist/module/Query.d.ts +3 -3
- package/dist/module/SuperToken.d.ts +2 -2
- package/dist/module/Token.d.ts +1 -1
- package/dist/module/index.d.ts +5 -5
- package/dist/module/index.js +6069 -6048
- package/dist/module/interfaces.d.ts +3 -6
- package/dist/module/ordering.d.ts +1 -1
- package/dist/module/pagination.d.ts +2 -2
- package/dist/module/subgraph/queries/getAllEvents.generated.d.ts +4 -4
- package/dist/module/subgraph/schema.generated.d.ts +33 -42
- package/dist/module/typechain/IResolver.d.ts +17 -3
- package/dist/module/typechain/TestToken.d.ts +8 -0
- package/dist/module/typechain/factories/IResolver__factory.d.ts +15 -2
- package/dist/module/validation.d.ts +1 -1
- package/dist/umd/BatchCall.d.ts +1 -1
- package/dist/umd/ConstantFlowAgreementV1.d.ts +2 -2
- package/dist/umd/Framework.d.ts +5 -5
- package/dist/umd/InstantDistributionAgreementV1.d.ts +2 -2
- package/dist/umd/Query.d.ts +3 -3
- package/dist/umd/SuperToken.d.ts +2 -2
- package/dist/umd/Token.d.ts +1 -1
- package/dist/umd/index.d.ts +5 -5
- package/dist/umd/index.js +4162 -4141
- package/dist/umd/interfaces.d.ts +3 -6
- package/dist/umd/ordering.d.ts +1 -1
- package/dist/umd/pagination.d.ts +2 -2
- package/dist/umd/subgraph/queries/getAllEvents.generated.d.ts +4 -4
- package/dist/umd/subgraph/schema.generated.d.ts +33 -42
- package/dist/umd/typechain/IResolver.d.ts +17 -3
- package/dist/umd/typechain/TestToken.d.ts +8 -0
- package/dist/umd/typechain/factories/IResolver__factory.d.ts +15 -2
- package/dist/umd/validation.d.ts +1 -1
- package/package.json +13 -8
package/README.md
CHANGED
|
@@ -116,12 +116,50 @@ const sf = await Framework.create({
|
|
|
116
116
|
provider
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
+
type Paging = { take: number, skip?: number, lastId?: string };
|
|
120
|
+
|
|
119
121
|
const pageResult = await sf.query.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
listAllResults(paging: Paging);
|
|
123
|
+
|
|
124
|
+
// The different queries can take different order by properties
|
|
125
|
+
// given the properties that exist on the entity itself.
|
|
126
|
+
listAllSuperTokens({ isListed?: boolean },
|
|
127
|
+
paging: Paging,
|
|
128
|
+
ordering: Ordering<Token_OrderBy>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
listIndexes({ indexId?: string, publisher?: string, token?: string },
|
|
132
|
+
paging: Paging,
|
|
133
|
+
ordering: Ordering<Index_OrderBy>
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
listIndexSubscriptions({ subscriber?: string, approved?: boolean },
|
|
137
|
+
paging: Paging,
|
|
138
|
+
ordering: Ordering<IndexSubscription_OrderBy>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
listStreams({ sender?: string, receiver?: string, token?: string },
|
|
142
|
+
paging: Paging,
|
|
143
|
+
ordering: Ordering<Stream_OrderBy>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
listUserInteractedSuperTokens({ account?: string, token?: string },
|
|
147
|
+
paging: Paging,
|
|
148
|
+
ordering: Ordering<AccountTokenSnapshot_OrderBy>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
listEvents({ account?: string, timestamp_gt?: number },
|
|
152
|
+
paging: Paging,
|
|
153
|
+
ordering: Ordering<Event_OrderBy>
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// A subscription function which allows you to subscribe to events via polling.
|
|
157
|
+
on(
|
|
158
|
+
callback: (events: AllEvents[], unsubscribe: () => void) => void,
|
|
159
|
+
ms: number,
|
|
160
|
+
account?: string,
|
|
161
|
+
timeout?: number
|
|
162
|
+
)
|
|
125
163
|
```
|
|
126
164
|
|
|
127
165
|
#### Direct Initialization
|
|
@@ -130,17 +168,45 @@ If you'd like, you can also initialize the `Query` class as a standalone class l
|
|
|
130
168
|
|
|
131
169
|
```ts
|
|
132
170
|
import { Query } from "@superfluid-finance/sdk-core";
|
|
133
|
-
const query = new Query({
|
|
134
|
-
|
|
135
|
-
|
|
171
|
+
const query = new Query({
|
|
172
|
+
customSubgraphQueriesEndpoint: "<A_CUSTOM_ENDPOINT>",
|
|
173
|
+
dataMode: "SUBGRAPH_ONLY" | "SUBGRAPH_WEB3" | "WEB3_ONLY"
|
|
174
|
+
});
|
|
136
175
|
```
|
|
137
176
|
|
|
138
177
|
#### Pagination
|
|
139
178
|
|
|
140
|
-
All of the pre-defined query functions will accept pagination options: `({ skip: number, take: number })`, if you don't pass anything in, it will use a default of: `{ skip: 0, take: 100 }`.
|
|
179
|
+
All of the pre-defined query functions will accept pagination options: `({ skip: number, take: number })`, if you don't pass anything in, it will use a default of: `{ skip: 0, take: 100 }`. You can also paginate by `lastId`, this allows you to bypass the limitation of the max skip of 5000 entities.
|
|
141
180
|
|
|
142
181
|
> Note: this example uses the `graphql-request` library, but you just need to provide a valid query which is a string.
|
|
143
182
|
|
|
183
|
+
#### Ordering
|
|
184
|
+
|
|
185
|
+
You can also pass in an ordering object for the different queries, each query function will accept different ordering properties depending on the properties on the entity. We have different defaults for each so you don't need to actually pass anything in.
|
|
186
|
+
|
|
187
|
+
#### Example Usage
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const { Framework } = require("@superfluid-finance/sdk-core");
|
|
191
|
+
const { ethers } = require("ethers");
|
|
192
|
+
|
|
193
|
+
const provider = new ethers.providers.InfuraProvider(
|
|
194
|
+
"matic",
|
|
195
|
+
"<INFURA_API_KEY>"
|
|
196
|
+
);
|
|
197
|
+
const sf = await Framework.create({
|
|
198
|
+
networkName: "matic",
|
|
199
|
+
provider
|
|
200
|
+
});
|
|
201
|
+
const results = await sf.query.listAllSuperTokens(
|
|
202
|
+
{ isListed: true },
|
|
203
|
+
{ skip: 5, take: 150 },
|
|
204
|
+
{
|
|
205
|
+
orderBy: "createdAtBlockNumber",
|
|
206
|
+
orderDirection: "desc"
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
144
210
|
### Creating a Signer
|
|
145
211
|
|
|
146
212
|
In order to execute a transaction on the blockchain, you need to have a signer. That is, you need to have access to an EOA (Externally Owned Account) to trigger any sort of change. You can do this through a contract, but an EOA still has to be the one which triggers the contract to interact with another contract. The signer that is returned will be passed when executing transactions.
|
|
@@ -278,15 +344,88 @@ const cfaV1 = new ConstantFlowAgreementV1({ options: config });
|
|
|
278
344
|
|
|
279
345
|
#### CFAV1 Functions
|
|
280
346
|
```ts
|
|
281
|
-
//
|
|
282
|
-
await sf.cfaV1.getFlow({
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await sf.cfaV1.
|
|
347
|
+
// Read functions
|
|
348
|
+
await sf.cfaV1.getFlow({
|
|
349
|
+
superToken: string,
|
|
350
|
+
sender: string,
|
|
351
|
+
receiver: string,
|
|
352
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
await sf.cfaV1.getAccountFlowInfo({
|
|
356
|
+
superToken: string,
|
|
357
|
+
account: string,
|
|
358
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
await sf.cfaV1.getNetFlow({
|
|
362
|
+
superToken: string,
|
|
363
|
+
account: string,
|
|
364
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
// Write operations
|
|
369
|
+
sf.cfaV1.createFlow({
|
|
370
|
+
sender: string,
|
|
371
|
+
receiver: string,
|
|
372
|
+
token: string,
|
|
373
|
+
flowRate: string,
|
|
374
|
+
userData?: string
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
sf.cfaV1.updateFlow({
|
|
378
|
+
sender: string,
|
|
379
|
+
receiver: string,
|
|
380
|
+
token: string,
|
|
381
|
+
flowRate: string,
|
|
382
|
+
userData?: string
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
sf.cfaV1.deleteFlow({
|
|
386
|
+
sender: string,
|
|
387
|
+
receiver: string,
|
|
388
|
+
token: string,
|
|
389
|
+
userData?: string
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
#### Example Usage
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
import { Framework } from "@superfluid-finance/sdk-core";
|
|
397
|
+
import { ethers } from "ethers";
|
|
398
|
+
|
|
399
|
+
const provider = new ethers.providers.InfuraProvider(
|
|
400
|
+
"matic",
|
|
401
|
+
"<INFURA_API_KEY>"
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
const sf = await Framework.create({
|
|
405
|
+
networkName: "matic",
|
|
406
|
+
provider
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// Read example
|
|
410
|
+
const flowInfo = await sf.cfaV1.getFlow({
|
|
411
|
+
superToken: "0x...",
|
|
412
|
+
sender: "0x...",
|
|
413
|
+
receiver: "0x...",
|
|
414
|
+
providerOrSigner: provider
|
|
415
|
+
});
|
|
416
|
+
console.log("flowInfo", flowInfo);
|
|
417
|
+
|
|
418
|
+
// Write operation example
|
|
419
|
+
const signer = sf.createSigner({ privateKey: "<TEST_ACCOUNT_PRIVATE_KEY>", provider });
|
|
420
|
+
const createFlowOperation = sf.cfaV1.createFlow({
|
|
421
|
+
sender: "0x...",
|
|
422
|
+
receiver: "0x...",
|
|
423
|
+
token: "0x...",
|
|
424
|
+
flowRate: "1000000000"
|
|
425
|
+
});
|
|
426
|
+
const txnResponse = await createFlowOperation.exec(signer);
|
|
427
|
+
const txnReceipt = await txnResponse.wait();
|
|
428
|
+
// Transaction Complete when code reaches here
|
|
290
429
|
```
|
|
291
430
|
|
|
292
431
|
### InstantDistributionAgreementV1
|
|
@@ -310,19 +449,110 @@ const idaV1 = new InstantDistributionAgreementV1({ options: config });
|
|
|
310
449
|
|
|
311
450
|
#### IDAV1 Functions
|
|
312
451
|
```ts
|
|
313
|
-
//
|
|
314
|
-
await sf.idaV1.getSubscription({
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
await sf.idaV1.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
452
|
+
// Read functions
|
|
453
|
+
await sf.idaV1.getSubscription({
|
|
454
|
+
superToken: string,
|
|
455
|
+
publisher: string,
|
|
456
|
+
indexId: string,
|
|
457
|
+
subscriber: string,
|
|
458
|
+
providerOrSigner: string
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
await sf.idaV1.getIndex({
|
|
462
|
+
superToken: string,
|
|
463
|
+
publisher: string,
|
|
464
|
+
indexId: string,
|
|
465
|
+
providerOrSigner: string
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
// Write operations
|
|
470
|
+
sf.idaV1.createIndex({
|
|
471
|
+
indexId: string,
|
|
472
|
+
superToken: string,
|
|
473
|
+
userData?: string
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
sf.idaV1.distribute({
|
|
477
|
+
indexId: string,
|
|
478
|
+
superToken: string,
|
|
479
|
+
amount: string,
|
|
480
|
+
userData?: string
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
sf.idaV1.updateIndexValue({
|
|
484
|
+
indexId: string,
|
|
485
|
+
superToken: string,
|
|
486
|
+
indexValue: string,
|
|
487
|
+
userData?: string
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
sf.idaV1.updateSubscriptionUnits({
|
|
491
|
+
indexId: string,
|
|
492
|
+
superToken: string,
|
|
493
|
+
subscriber: string,
|
|
494
|
+
units: string,
|
|
495
|
+
userData?: string
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
sf.idaV1.approveSubscription({
|
|
499
|
+
indexId: string,
|
|
500
|
+
superToken: string,
|
|
501
|
+
publisher: string,
|
|
502
|
+
userData?: string
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
sf.idaV1.revokeSubscription({
|
|
506
|
+
indexId: string,
|
|
507
|
+
superToken: string,
|
|
508
|
+
publisher: string,
|
|
509
|
+
userData?: string
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
sf.idaV1.deleteSubscription({
|
|
513
|
+
indexId: string,
|
|
514
|
+
superToken: string,
|
|
515
|
+
subscriber: string,
|
|
516
|
+
publisher: string,
|
|
517
|
+
userData?: string
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
sf.idaV1.claim({
|
|
521
|
+
indexId: string,
|
|
522
|
+
superToken: string,
|
|
523
|
+
subscriber: string,
|
|
524
|
+
publisher: string,
|
|
525
|
+
userData?: string
|
|
526
|
+
});
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
#### Example Usage
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
import { Framework } from "@superfluid-finance/sdk-core";
|
|
533
|
+
import { ethers } from "ethers";
|
|
534
|
+
|
|
535
|
+
const provider = new ethers.providers.InfuraProvider(
|
|
536
|
+
"matic",
|
|
537
|
+
"<INFURA_API_KEY>"
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
const sf = await Framework.create({
|
|
541
|
+
networkName: "matic",
|
|
542
|
+
provider
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// Read example
|
|
546
|
+
const subscription = await sf.idaV1.getSubscription({ superToken: "0x...", publisher: "0x...", indexId: "1", subscriber: "0x...", providerOrSigner: provider });
|
|
547
|
+
console.log(subscription);
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
// Write operation example
|
|
551
|
+
const signer = sf.createSigner({ privateKey: "<TEST_ACCOUNT_PRIVATE_KEY>", provider });
|
|
552
|
+
const createIndexOperation = sf.idaV1.createIndex({ indexId: "0", userData: "0x" });
|
|
553
|
+
const txnResponse = await createIndexOperation.exec(signer);
|
|
554
|
+
const txnReceipt = await txnResponse.wait();
|
|
555
|
+
// Transaction Complete when code reaches here
|
|
326
556
|
```
|
|
327
557
|
|
|
328
558
|
### SuperToken
|
|
@@ -358,7 +588,6 @@ const provider = new ethers.providers.InfuraProvider(
|
|
|
358
588
|
"matic",
|
|
359
589
|
"<INFURA_API_KEY>"
|
|
360
590
|
);
|
|
361
|
-
let usdcx: SuperToken;
|
|
362
591
|
|
|
363
592
|
const config = {
|
|
364
593
|
hostAddress: "0x3E14dC1b13c488a8d5D310918780c983bD5982E7",
|
|
@@ -367,7 +596,7 @@ const config = {
|
|
|
367
596
|
idaV1Address: "0xB0aABBA4B2783A72C52956CDEF62d438ecA2d7a1"
|
|
368
597
|
};
|
|
369
598
|
|
|
370
|
-
usdcx = await SuperToken.create({
|
|
599
|
+
const usdcx = await SuperToken.create({
|
|
371
600
|
address: "0xCAa7349CEA390F89641fe306D93591f87595dc1F",
|
|
372
601
|
config,
|
|
373
602
|
networkName: "matic",
|
|
@@ -380,32 +609,103 @@ usdcx = await SuperToken.create({
|
|
|
380
609
|
```ts
|
|
381
610
|
const usdcx = sf.loadToken("0xCAa7349CEA390F89641fe306D93591f87595dc1F");
|
|
382
611
|
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
await usdcx.balanceOf({
|
|
386
|
-
|
|
387
|
-
|
|
612
|
+
// ERC20 `Token`
|
|
613
|
+
// Read functions
|
|
614
|
+
await usdcx.balanceOf({
|
|
615
|
+
account: string,
|
|
616
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
await usdcx.allowance({
|
|
620
|
+
owner: string,
|
|
621
|
+
spender: string,
|
|
622
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
await usdcx.name({
|
|
626
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
await usdcx.symbol({
|
|
630
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
await usdcx.totalSupply({
|
|
634
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
// Write operations
|
|
639
|
+
usdcx.approve({
|
|
640
|
+
recipient: string,
|
|
641
|
+
amount: string
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
usdcx.transfer({
|
|
645
|
+
recipient: string,
|
|
646
|
+
amount: string
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
usdcx.transferFrom({
|
|
650
|
+
sender: string,
|
|
651
|
+
recipient: string,
|
|
652
|
+
amount: string
|
|
653
|
+
});
|
|
388
654
|
|
|
389
655
|
// `SuperToken` only function
|
|
390
|
-
await usdcx.realtimeBalanceOf({
|
|
656
|
+
await usdcx.realtimeBalanceOf({
|
|
657
|
+
account: string,
|
|
658
|
+
timestamp: string,
|
|
659
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer
|
|
660
|
+
});
|
|
391
661
|
|
|
392
662
|
// Write Functions
|
|
663
|
+
|
|
393
664
|
// All write functions return Promise<Operation>
|
|
394
665
|
|
|
395
|
-
// SuperToken Write
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
await usdcx.transferFrom({ sender: string, recipient: string, amount: string });
|
|
400
|
-
await usdcx.upgrade({ amount: string });
|
|
666
|
+
// SuperToken Write operations
|
|
667
|
+
usdcx.downgrade({ amount: string });
|
|
668
|
+
|
|
669
|
+
usdcx.upgrade({ amount: string });
|
|
401
670
|
|
|
402
671
|
// SuperToken CFAV1/IDAV1 Functions are the same as the
|
|
403
672
|
// ConstantFlowAgreementV1/InstantDistributionAgreementV1 class functions
|
|
404
673
|
// except instead of the sf.cfaV1/idaV1.function() signature, it is token.function()
|
|
674
|
+
// e.g. await usdcx.createIndex({ indexId: "0", userData: "0x" }).exec(signer);
|
|
405
675
|
// and you don't need to pass in a token as a parameter as it uses the token address
|
|
406
676
|
// of the instantiated class.
|
|
407
677
|
```
|
|
408
678
|
|
|
679
|
+
#### Example Usage
|
|
680
|
+
|
|
681
|
+
```ts
|
|
682
|
+
import { Framework } from "@superfluid-finance/sdk-core";
|
|
683
|
+
import { ethers } from "ethers";
|
|
684
|
+
|
|
685
|
+
const provider = new ethers.providers.InfuraProvider(
|
|
686
|
+
"matic",
|
|
687
|
+
"<INFURA_API_KEY>"
|
|
688
|
+
);
|
|
689
|
+
|
|
690
|
+
const sf = await Framework.create({
|
|
691
|
+
networkName: "matic",
|
|
692
|
+
provider
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
const usdcx = sf.loadToken("0xCAa7349CEA390F89641fe306D93591f87595dc1F");
|
|
696
|
+
|
|
697
|
+
// Read example
|
|
698
|
+
const name = await usdcx.name();
|
|
699
|
+
console.log(name);
|
|
700
|
+
|
|
701
|
+
// Write operation example
|
|
702
|
+
const signer = sf.createSigner({ privateKey: "<TEST_ACCOUNT_PRIVATE_KEY>", provider });
|
|
703
|
+
const transferOperation = usdcx.transfer({ receiver: "0x...", amount: "1000000" });
|
|
704
|
+
const txnResponse = await transferOperation.exec(signer);
|
|
705
|
+
const txnReceipt = await txnResponse.wait();
|
|
706
|
+
// Transaction Complete when code reaches here
|
|
707
|
+
```
|
|
708
|
+
|
|
409
709
|
> Note: you can also get the underlying Token object which only has ERC20 token read/write methods-this is useful for things like approving token spend to a SuperToken contract prior to upgrading for example.
|
|
410
710
|
|
|
411
711
|
```ts
|
|
@@ -421,12 +721,12 @@ The `BatchCall` class allows the user to batch multiple supported operations/tra
|
|
|
421
721
|
|
|
422
722
|
Not all operations are supported by the batch call feature, below is a list of the supported operations:
|
|
423
723
|
|
|
424
|
-
- ERC20_APPROVE (SuperToken only)
|
|
425
|
-
- ERC20_TRANSFER_FROM
|
|
426
|
-
- SUPERTOKEN_UPGRADE
|
|
427
|
-
- SUPERTOKEN_DOWNGRADE
|
|
428
|
-
- SUPERFLUID_CALL_AGREEMENT
|
|
429
|
-
- CALL_APP_ACTION
|
|
724
|
+
- `ERC20_APPROVE (SuperToken only)`
|
|
725
|
+
- `ERC20_TRANSFER_FROM`
|
|
726
|
+
- `SUPERTOKEN_UPGRADE`
|
|
727
|
+
- `SUPERTOKEN_DOWNGRADE`
|
|
728
|
+
- `SUPERFLUID_CALL_AGREEMENT`
|
|
729
|
+
- `CALL_APP_ACTION`
|
|
430
730
|
|
|
431
731
|
Most of the token methods are self explanatory, but some additional context for the last two operations is helpful.
|
|
432
732
|
`SUPERFLUID_CALL_AGREEMENT` refers to all operations related to the CFA or IDA (`createFlow`, `updateIndex`, `distribute`, etc.).
|
|
@@ -473,7 +773,32 @@ const batchCall = new BatchCall({
|
|
|
473
773
|
#### Usage
|
|
474
774
|
|
|
475
775
|
```ts
|
|
476
|
-
|
|
776
|
+
import { Framework } from "@superfluid-finance/sdk-core";
|
|
777
|
+
import { ethers } from "ethers";
|
|
778
|
+
|
|
779
|
+
const provider = new ethers.providers.InfuraProvider(
|
|
780
|
+
"matic",
|
|
781
|
+
"<INFURA_API_KEY>"
|
|
782
|
+
);
|
|
783
|
+
|
|
784
|
+
const sf = await Framework.create({
|
|
785
|
+
networkName: "matic",
|
|
786
|
+
provider
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
// 0xabc is the signer on Rinkeby testnet
|
|
790
|
+
const signer = sf.createSigner({ privateKey: "<TEST_ACCOUNT_PRIVATE_KEY>", provider });
|
|
791
|
+
const daix = await sf.loadSuperToken("0x745861AeD1EEe363b4AaA5F1994Be40b1e05Ff90");
|
|
792
|
+
const fromAddress = "0xabc";
|
|
793
|
+
const paymentAddress = "0xdef";
|
|
794
|
+
const approveOp = daix.approve({ receiver: paymentAddress, amount: "10000" });
|
|
795
|
+
const transferFromOp = daix.transferFrom({
|
|
796
|
+
sender: fromAddress,
|
|
797
|
+
receiver: paymentAddress,
|
|
798
|
+
amount: "10000",
|
|
799
|
+
});
|
|
800
|
+
const batchCall = sf.batchCall([approveOp, transferFromOp]);
|
|
801
|
+
const txn = await batchCall.exec(signer);
|
|
477
802
|
|
|
478
803
|
// creating an operation from a super app function
|
|
479
804
|
// initialize your super app contract
|
|
@@ -483,5 +808,5 @@ const superApp = new ethers.Contract("0x...", <SUPER_APP_ABI>);
|
|
|
483
808
|
const superAppTransactionPromise = superApp.populateTransaction.helloWorld("hello world");
|
|
484
809
|
|
|
485
810
|
// create the super app operation you can execute this operation directly or pass it in to a batch call
|
|
486
|
-
const superAppOperation = new Operation(
|
|
811
|
+
const superAppOperation = new Operation(superAppTransactionPromise, "CALL_APP_ACTION");
|
|
487
812
|
```
|
package/dist/main/BatchCall.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import Host from "./Host";
|
|
3
|
-
import { IConfig } from "./interfaces";
|
|
4
3
|
import Operation from "./Operation";
|
|
4
|
+
import { IConfig } from "./interfaces";
|
|
5
5
|
interface IBatchCallOptions {
|
|
6
6
|
config: IConfig;
|
|
7
7
|
operations: ReadonlyArray<Operation>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAgreementV1Options, ICreateFlowParams, IDeleteFlowParams, IUpdateFlowParams, IGetFlowParams, IGetAccountFlowInfoParams, IWeb3FlowInfoParams, IWeb3FlowInfo } from "./interfaces";
|
|
2
|
-
import Operation from "./Operation";
|
|
3
1
|
import Host from "./Host";
|
|
2
|
+
import Operation from "./Operation";
|
|
3
|
+
import { IAgreementV1Options, ICreateFlowParams, IDeleteFlowParams, IGetAccountFlowInfoParams, IGetFlowParams, IUpdateFlowParams, IWeb3FlowInfo, IWeb3FlowInfoParams } from "./interfaces";
|
|
4
4
|
/**
|
|
5
5
|
* @dev Constant Flow Agreement V1 Helper Class
|
|
6
6
|
* @description A helper class to interact with the CFAV1 contract.
|
package/dist/main/Framework.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
1
|
import { Signer } from "@ethersproject/abstract-signer";
|
|
3
|
-
import {
|
|
4
|
-
import { DataMode } from "./types";
|
|
2
|
+
import { ethers } from "ethers";
|
|
5
3
|
import BatchCall from "./BatchCall";
|
|
6
4
|
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
7
5
|
import Host from "./Host";
|
|
8
6
|
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
9
|
-
import SuperToken from "./SuperToken";
|
|
10
|
-
import Query from "./Query";
|
|
11
7
|
import Operation from "./Operation";
|
|
8
|
+
import Query from "./Query";
|
|
9
|
+
import SuperToken from "./SuperToken";
|
|
10
|
+
import { IConfig, ISignerConstructorOptions } from "./interfaces";
|
|
11
|
+
import { DataMode } from "./types";
|
|
12
12
|
export interface IFrameworkOptions {
|
|
13
13
|
chainId?: number;
|
|
14
14
|
customSubgraphQueriesEndpoint?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAgreementV1Options, IBaseIDAParams, IBaseSubscriptionParams, IDistributeParams, IGetIndexParams, IGetSubscriptionParams, IUpdateIndexValueParams, IUpdateSubscriptionUnitsParams, IWeb3Index, IWeb3Subscription } from "./interfaces";
|
|
2
|
-
import Operation from "./Operation";
|
|
3
1
|
import Host from "./Host";
|
|
2
|
+
import Operation from "./Operation";
|
|
3
|
+
import { IAgreementV1Options, IBaseIDAParams, IBaseSubscriptionParams, IDistributeParams, IGetIndexParams, IGetSubscriptionParams, IUpdateIndexValueParams, IUpdateSubscriptionUnitsParams, IWeb3Index, IWeb3Subscription } from "./interfaces";
|
|
4
4
|
/**
|
|
5
5
|
* @dev Instant Distribution Agreement V1 Helper Class
|
|
6
6
|
* @description A helper class to interact with the IDAV1 contract.
|
package/dist/main/Query.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IAccountTokenSnapshotFilter, IIndex, IIndexRequestFilter, IIndexSubscription, IIndexSubscriptionRequestFilter, ILightAccountTokenSnapshot, ILightEntity, IStream, IStreamRequestFilter, ISuperToken, ISuperTokenRequestFilter } from "./interfaces";
|
|
2
|
-
import { DataMode } from "./types";
|
|
3
|
-
import { PagedResult, Paging } from "./pagination";
|
|
4
1
|
import { AllEvents, IEventFilter } from "./events";
|
|
2
|
+
import { IAccountTokenSnapshotFilter, IIndex, IIndexRequestFilter, IIndexSubscription, IIndexSubscriptionRequestFilter, ILightAccountTokenSnapshot, ILightEntity, IStream, IStreamRequestFilter, ISuperToken, ISuperTokenRequestFilter } from "./interfaces";
|
|
5
3
|
import { Ordering } from "./ordering";
|
|
4
|
+
import { PagedResult, Paging } from "./pagination";
|
|
6
5
|
import { AccountTokenSnapshot_OrderBy, Event_OrderBy, Index_OrderBy, IndexSubscription_OrderBy, Stream_OrderBy, Token_OrderBy } from "./subgraph/schema.generated";
|
|
6
|
+
import { DataMode } from "./types";
|
|
7
7
|
export interface IQueryOptions {
|
|
8
8
|
readonly customSubgraphQueriesEndpoint: string;
|
|
9
9
|
readonly dataMode: DataMode;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { IConfig, IRealtimeBalanceOfParams, ISuperTokenBaseIDAParams, ISuperTokenCreateFlowParams, ISuperTokenDeleteFlowParams, ISuperTokenDistributeParams, ISuperTokenGetFlowInfoParams, ISuperTokenGetFlowParams, ISuperTokenGetIndexParams, ISuperTokenGetSubscriptionParams, ISuperTokenPublisherOperationParams, ISuperTokenPubSubParams, ISuperTokenUpdateFlowParams, ISuperTokenUpdateIndexValueParams, ISuperTokenUpdateSubscriptionUnitsParams, IWeb3FlowInfo, IWeb3Index, IWeb3RealTimeBalanceOf, IWeb3Subscription } from "./interfaces";
|
|
3
|
-
import Operation from "./Operation";
|
|
4
2
|
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
5
3
|
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
4
|
+
import Operation from "./Operation";
|
|
6
5
|
import Token from "./Token";
|
|
6
|
+
import { IConfig, IRealtimeBalanceOfParams, ISuperTokenBaseIDAParams, ISuperTokenCreateFlowParams, ISuperTokenDeleteFlowParams, ISuperTokenDistributeParams, ISuperTokenGetFlowInfoParams, ISuperTokenGetFlowParams, ISuperTokenGetIndexParams, ISuperTokenGetSubscriptionParams, ISuperTokenPublisherOperationParams, ISuperTokenPubSubParams, ISuperTokenUpdateFlowParams, ISuperTokenUpdateIndexValueParams, ISuperTokenUpdateSubscriptionUnitsParams, IWeb3FlowInfo, IWeb3Index, IWeb3RealTimeBalanceOf, IWeb3Subscription } from "./interfaces";
|
|
7
7
|
export interface ITokenSettings {
|
|
8
8
|
readonly address: string;
|
|
9
9
|
readonly config: IConfig;
|
package/dist/main/Token.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import { IBaseSuperTokenParams, ITransferFromParams } from "./interfaces";
|
|
3
2
|
import Operation from "./Operation";
|
|
3
|
+
import { IBaseSuperTokenParams, ITransferFromParams } from "./interfaces";
|
|
4
4
|
export default class Token {
|
|
5
5
|
readonly address: string;
|
|
6
6
|
constructor(address: string);
|
package/dist/main/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import SuperToken from "./SuperToken";
|
|
3
|
-
import Query from "./Query";
|
|
1
|
+
import BatchCall from "./BatchCall";
|
|
4
2
|
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
5
|
-
import
|
|
3
|
+
import Framework from "./Framework";
|
|
6
4
|
import Host from "./Host";
|
|
7
|
-
import
|
|
5
|
+
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
6
|
+
import Query from "./Query";
|
|
7
|
+
import SuperToken from "./SuperToken";
|
|
8
8
|
export * from "./interfaces";
|
|
9
9
|
export * from "./utils";
|
|
10
10
|
export * from "./pagination";
|