@superfluid-finance/sdk-core 0.1.1-dev.86e9998.0 → 0.1.1-dev.d7f58c8.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 +61 -36
- 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/constants.d.ts +8 -1
- package/dist/main/index.d.ts +5 -5
- package/dist/main/index.js +6081 -6006
- 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/utils.d.ts +17 -0
- 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/constants.d.ts +8 -1
- package/dist/module/index.d.ts +5 -5
- package/dist/module/index.js +6080 -6007
- 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/utils.d.ts +17 -0
- 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/constants.d.ts +8 -1
- package/dist/umd/index.d.ts +5 -5
- package/dist/umd/index.js +4320 -4245
- 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/utils.d.ts +17 -0
- package/dist/umd/validation.d.ts +1 -1
- package/package.json +13 -8
package/README.md
CHANGED
|
@@ -37,12 +37,24 @@ yarn install && yarn build
|
|
|
37
37
|
|
|
38
38
|
Here is a quick look at initializing the SDK in different environments:
|
|
39
39
|
|
|
40
|
-
TypeScript / JavaScript (Module)
|
|
40
|
+
TypeScript / JavaScript (Module) vs. JavaScript (CommonJS) - usually a Node.js environment
|
|
41
41
|
|
|
42
|
+
The primary difference between the two environments is the import/require of the sdk-core package, everything else is the same.
|
|
43
|
+
|
|
44
|
+
TS/ESModule
|
|
42
45
|
```ts
|
|
43
46
|
import { Framework } from "@superfluid-finance/sdk-core";
|
|
44
47
|
import { ethers } from "ethers";
|
|
48
|
+
```
|
|
45
49
|
|
|
50
|
+
CommonJS/Node.js
|
|
51
|
+
```js
|
|
52
|
+
const { Framework } = require("@superfluid-finance/sdk-core");
|
|
53
|
+
const { ethers } = require("ethers");
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
// infura provider initialization
|
|
46
58
|
const provider = new ethers.providers.InfuraProvider(
|
|
47
59
|
"matic",
|
|
48
60
|
"<INFURA_API_KEY>"
|
|
@@ -60,31 +72,45 @@ const web3jsSf = await Framework.create({
|
|
|
60
72
|
networkName: "matic",
|
|
61
73
|
provider: web3jsProvider
|
|
62
74
|
});
|
|
63
|
-
```
|
|
64
75
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const { ethers } = require("ethers");
|
|
70
|
-
|
|
71
|
-
const provider = new ethers.providers.InfuraProvider(
|
|
72
|
-
"matic",
|
|
73
|
-
"<INFURA_API_KEY>"
|
|
74
|
-
);
|
|
75
|
-
const sf = await Framework.create({
|
|
76
|
+
// ethers.js + hardhat provider initialization (in testing environment w/ hardhat-ethers)
|
|
77
|
+
const [deployer] = await ethers.getSigners();
|
|
78
|
+
const ethersProvider = deployer.provider;
|
|
79
|
+
const ethersjsSf = await Framework.create({
|
|
76
80
|
networkName: "matic",
|
|
77
|
-
provider
|
|
81
|
+
provider: ethersProvider
|
|
78
82
|
});
|
|
79
83
|
|
|
80
|
-
//
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
const web3jsSf = await Framework.create({
|
|
84
|
+
// metamask
|
|
85
|
+
const mmProvider = new ethers.providers.Web3Provider(window.ethereum);
|
|
86
|
+
const mmSf = await Framework.create({
|
|
85
87
|
networkName: "matic",
|
|
86
|
-
provider:
|
|
88
|
+
provider: mmProvider
|
|
87
89
|
});
|
|
90
|
+
|
|
91
|
+
// web3modal
|
|
92
|
+
const web3ModalRawProvider = await web3Modal.connect();
|
|
93
|
+
const web3ModalProvider = new ethers.providers.Web3Provider(web3ModalRawProvider);
|
|
94
|
+
const web3ModalSf = await Framework.create({
|
|
95
|
+
networkName: "matic",
|
|
96
|
+
provider: web3ModalProvider
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
//bnc-onboard
|
|
100
|
+
const onboard = Onboard({
|
|
101
|
+
dappId: "<API_KEY>",
|
|
102
|
+
networkId: 4,
|
|
103
|
+
subscriptions: {
|
|
104
|
+
wallet: wallet => {
|
|
105
|
+
const web3Provider = new ethers.providers.Web3Provider(wallet.provider);
|
|
106
|
+
(async () => {
|
|
107
|
+
const framework = await Framework.create({ networkName: "matic", provider: web3Provider });
|
|
108
|
+
})();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// this is triggered by:
|
|
113
|
+
await onboard.walletSelect();
|
|
88
114
|
```
|
|
89
115
|
|
|
90
116
|
> Note: You specify your project type in `package.json` - `"type": "module"` or `"type": "commonjs"`.
|
|
@@ -229,11 +255,11 @@ const sf = await Framework.create({
|
|
|
229
255
|
provider: web3ModalProvider,
|
|
230
256
|
});
|
|
231
257
|
|
|
232
|
-
const web3ModalSigner = sf.createSigner(web3ModalProvider);
|
|
258
|
+
const web3ModalSigner = sf.createSigner({ web3Provider: web3ModalProvider });
|
|
233
259
|
|
|
234
260
|
// MetaMask example
|
|
235
261
|
const metamaskProvider = new Web3Provider(window.ethereum);
|
|
236
|
-
const metaMaskSigner = sf.createSigner(metamaskProvider);
|
|
262
|
+
const metaMaskSigner = sf.createSigner({ web3Provider: metamaskProvider });
|
|
237
263
|
```
|
|
238
264
|
|
|
239
265
|
#### Hardhat Signer Example
|
|
@@ -278,9 +304,7 @@ const sf = await Framework.create({
|
|
|
278
304
|
provider,
|
|
279
305
|
});
|
|
280
306
|
|
|
281
|
-
const signer = sf.createSigner({
|
|
282
|
-
signer: wallet
|
|
283
|
-
});
|
|
307
|
+
const signer = sf.createSigner({ signer: wallet });
|
|
284
308
|
```
|
|
285
309
|
|
|
286
310
|
### Operation
|
|
@@ -786,18 +810,19 @@ const sf = await Framework.create({
|
|
|
786
810
|
provider
|
|
787
811
|
});
|
|
788
812
|
|
|
789
|
-
// 0xabc is the signer
|
|
813
|
+
// 0xabc is the signer on Rinkeby testnet
|
|
790
814
|
const signer = sf.createSigner({ privateKey: "<TEST_ACCOUNT_PRIVATE_KEY>", provider });
|
|
791
|
-
const
|
|
792
|
-
const
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
815
|
+
const daix = await sf.loadSuperToken("0x745861AeD1EEe363b4AaA5F1994Be40b1e05Ff90");
|
|
816
|
+
const fromAddress = "0xabc";
|
|
817
|
+
const paymentAddress = "0xdef";
|
|
818
|
+
const approveOp = daix.approve({ receiver: paymentAddress, amount: "10000" });
|
|
819
|
+
const transferFromOp = daix.transferFrom({
|
|
820
|
+
sender: fromAddress,
|
|
821
|
+
receiver: paymentAddress,
|
|
822
|
+
amount: "10000",
|
|
823
|
+
});
|
|
824
|
+
const batchCall = sf.batchCall([approveOp, transferFromOp]);
|
|
825
|
+
const txn = await batchCall.exec(signer);
|
|
801
826
|
|
|
802
827
|
// creating an operation from a super app function
|
|
803
828
|
// initialize your super app contract
|
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/constants.d.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { IResolverData } from "./interfaces";
|
|
2
2
|
export declare const MONTHS_PER_YEAR = 12;
|
|
3
3
|
export declare const DAYS_PER_MONTH = 30;
|
|
4
|
+
export declare const DAYS_PER_WEEK = 7;
|
|
4
5
|
export declare const HOURS_PER_DAY = 24;
|
|
5
6
|
export declare const MINUTES_PER_HOUR = 60;
|
|
6
|
-
export declare const
|
|
7
|
+
export declare const MINUTE_IN_SECONDS = 60;
|
|
8
|
+
export declare const HOUR_IN_SECONDS: number;
|
|
9
|
+
export declare const DAY_IN_SECONDS: number;
|
|
10
|
+
export declare const WEEK_IN_SECONDS: number;
|
|
11
|
+
export declare const MONTH_IN_SECONDS: number;
|
|
12
|
+
export declare const YEAR_IN_SECONDS: number;
|
|
13
|
+
export declare const BASE_18 = 10000000000000000000;
|
|
7
14
|
export declare const chainIds: number[];
|
|
8
15
|
export declare const networkNames: string[];
|
|
9
16
|
export declare const chainIdToDataMap: Map<number, IResolverData>;
|
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";
|