@nevermined-io/core-kit 0.0.2-rc19
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 +15 -0
- package/dist/Instantiable.abstract.d.ts +35 -0
- package/dist/Instantiable.abstract.d.ts.map +1 -0
- package/dist/Instantiable.abstract.js +102 -0
- package/dist/artifacts/generated.d.ts +29912 -0
- package/dist/artifacts/generated.d.ts.map +1 -0
- package/dist/artifacts/generated.js +16797 -0
- package/dist/contracts/AccessManager.d.ts +17 -0
- package/dist/contracts/AccessManager.d.ts.map +1 -0
- package/dist/contracts/AccessManager.js +15 -0
- package/dist/contracts/AssetRegistry.d.ts +65 -0
- package/dist/contracts/AssetRegistry.d.ts.map +1 -0
- package/dist/contracts/AssetRegistry.js +103 -0
- package/dist/contracts/ContractBase.d.ts +21 -0
- package/dist/contracts/ContractBase.d.ts.map +1 -0
- package/dist/contracts/ContractBase.js +270 -0
- package/dist/contracts/ContractsApi.d.ts +62 -0
- package/dist/contracts/ContractsApi.d.ts.map +1 -0
- package/dist/contracts/ContractsApi.js +66 -0
- package/dist/contracts/FiatPaymentTemplate.d.ts +10 -0
- package/dist/contracts/FiatPaymentTemplate.d.ts.map +1 -0
- package/dist/contracts/FiatPaymentTemplate.js +14 -0
- package/dist/contracts/FiatSettlementCondition.d.ts +11 -0
- package/dist/contracts/FiatSettlementCondition.d.ts.map +1 -0
- package/dist/contracts/FiatSettlementCondition.js +18 -0
- package/dist/contracts/FixedPaymentTemplate.d.ts +10 -0
- package/dist/contracts/FixedPaymentTemplate.d.ts.map +1 -0
- package/dist/contracts/FixedPaymentTemplate.js +14 -0
- package/dist/contracts/NFT1155Base.d.ts +41 -0
- package/dist/contracts/NFT1155Base.d.ts.map +1 -0
- package/dist/contracts/NFT1155Base.js +21 -0
- package/dist/contracts/NFT1155Credits.d.ts +6 -0
- package/dist/contracts/NFT1155Credits.d.ts.map +1 -0
- package/dist/contracts/NFT1155Credits.js +9 -0
- package/dist/contracts/NFT1155ExpirableCredits.d.ts +34 -0
- package/dist/contracts/NFT1155ExpirableCredits.d.ts.map +1 -0
- package/dist/contracts/NFT1155ExpirableCredits.js +18 -0
- package/dist/contracts/NVMConfig.d.ts +10 -0
- package/dist/contracts/NVMConfig.d.ts.map +1 -0
- package/dist/contracts/NVMConfig.js +18 -0
- package/dist/contracts/ProtocolStandardFees.d.ts +9 -0
- package/dist/contracts/ProtocolStandardFees.d.ts.map +1 -0
- package/dist/contracts/ProtocolStandardFees.js +15 -0
- package/dist/contracts/Roles.d.ts +13 -0
- package/dist/contracts/Roles.d.ts.map +1 -0
- package/dist/contracts/Roles.js +12 -0
- package/dist/contracts/index.d.ts +3 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +2 -0
- package/dist/errors/NeverminedErrors.d.ts +71 -0
- package/dist/errors/NeverminedErrors.d.ts.map +1 -0
- package/dist/errors/NeverminedErrors.js +123 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/models/Logger.d.ts +9 -0
- package/dist/models/Logger.d.ts.map +1 -0
- package/dist/models/Logger.js +27 -0
- package/dist/models/NeverminedOptions.d.ts +55 -0
- package/dist/models/NeverminedOptions.d.ts.map +1 -0
- package/dist/models/NeverminedOptions.js +58 -0
- package/dist/models/NvmApiKey.d.ts +137 -0
- package/dist/models/NvmApiKey.d.ts.map +1 -0
- package/dist/models/NvmApiKey.js +234 -0
- package/dist/models/Transactions.d.ts +11 -0
- package/dist/models/Transactions.d.ts.map +1 -0
- package/dist/models/Transactions.js +1 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +4 -0
- package/dist/nevermined/DID.d.ts +45 -0
- package/dist/nevermined/DID.d.ts.map +1 -0
- package/dist/nevermined/DID.js +90 -0
- package/dist/nevermined/Nevermined.d.ts +48 -0
- package/dist/nevermined/Nevermined.d.ts.map +1 -0
- package/dist/nevermined/Nevermined.js +72 -0
- package/dist/nevermined/api/PaymentsApi.d.ts +17 -0
- package/dist/nevermined/api/PaymentsApi.d.ts.map +1 -0
- package/dist/nevermined/api/PaymentsApi.js +125 -0
- package/dist/nevermined/api/ServicesApi.d.ts +28 -0
- package/dist/nevermined/api/ServicesApi.d.ts.map +1 -0
- package/dist/nevermined/api/ServicesApi.js +33 -0
- package/dist/nevermined/api/UtilsApi.d.ts +28 -0
- package/dist/nevermined/api/UtilsApi.d.ts.map +1 -0
- package/dist/nevermined/api/UtilsApi.js +33 -0
- package/dist/nevermined/index.d.ts +4 -0
- package/dist/nevermined/index.d.ts.map +1 -0
- package/dist/nevermined/index.js +3 -0
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +276 -0
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +1 -0
- package/dist/nevermined/utils/BlockchainViemUtils.js +376 -0
- package/dist/nevermined/utils/JwtUtils.d.ts +27 -0
- package/dist/nevermined/utils/JwtUtils.d.ts.map +1 -0
- package/dist/nevermined/utils/JwtUtils.js +154 -0
- package/dist/nevermined/utils/SignatureUtils.d.ts +14 -0
- package/dist/nevermined/utils/SignatureUtils.d.ts.map +1 -0
- package/dist/nevermined/utils/SignatureUtils.js +99 -0
- package/dist/nevermined/utils/WebServiceConnector.d.ts +32 -0
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +1 -0
- package/dist/nevermined/utils/WebServiceConnector.js +191 -0
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts +19 -0
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +1 -0
- package/dist/nevermined/utils/ZeroDevPolicies.js +78 -0
- package/dist/nevermined/utils/index.d.ts +6 -0
- package/dist/nevermined/utils/index.d.ts.map +1 -0
- package/dist/nevermined/utils/index.js +5 -0
- package/dist/services/Api.d.ts +7 -0
- package/dist/services/Api.d.ts.map +1 -0
- package/dist/services/Api.js +25 -0
- package/dist/services/MarketplaceAPI.d.ts +7 -0
- package/dist/services/MarketplaceAPI.d.ts.map +1 -0
- package/dist/services/MarketplaceAPI.js +25 -0
- package/dist/services/MetadataService.d.ts +90 -0
- package/dist/services/MetadataService.d.ts.map +1 -0
- package/dist/services/MetadataService.js +277 -0
- package/dist/services/Profiles.d.ts +16 -0
- package/dist/services/Profiles.d.ts.map +1 -0
- package/dist/services/Profiles.js +84 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +3 -0
- package/dist/utils/ConversionTypeHelpers.d.ts +8 -0
- package/dist/utils/ConversionTypeHelpers.d.ts.map +1 -0
- package/dist/utils/ConversionTypeHelpers.js +31 -0
- package/dist/utils/Network.d.ts +5 -0
- package/dist/utils/Network.d.ts.map +1 -0
- package/dist/utils/Network.js +224 -0
- package/dist/utils/helpers.d.ts +21 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +109 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/package.json +27 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Account, Address, TransactionReceipt } from 'viem';
|
|
2
|
+
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
3
|
+
import { ContractBase } from './ContractBase.js';
|
|
4
|
+
import { SmartAccount, UserOperationReceipt } from 'viem/account-abstraction';
|
|
5
|
+
import { TxParameters } from '../models/Transactions.js';
|
|
6
|
+
export declare class AccessManager extends ContractBase {
|
|
7
|
+
static getInstance(config: InstantiableConfig): Promise<AccessManager>;
|
|
8
|
+
hasRole(roleId: bigint, address: Address): Promise<[boolean, bigint]>;
|
|
9
|
+
grantRole({ address, roleId, executionDelay, owner, txParams, }: {
|
|
10
|
+
address: Address;
|
|
11
|
+
roleId: bigint;
|
|
12
|
+
executionDelay?: number;
|
|
13
|
+
owner: Account | SmartAccount;
|
|
14
|
+
txParams?: TxParameters;
|
|
15
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=AccessManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccessManager.d.ts","sourceRoot":"","sources":["../../src/contracts/AccessManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,qBAAa,aAAc,SAAQ,YAAY;WAChB,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAS/E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAGrE,SAAS,CAAC,EACrB,OAAO,EACP,MAAM,EACN,cAAc,EACd,KAAK,EACL,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,OAAO,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,KAAK,EAAE,OAAO,GAAG,YAAY,CAAA;QAC7B,QAAQ,CAAC,EAAE,YAAY,CAAA;KACxB,GAAG,OAAO,CAAC,kBAAkB,GAAG,oBAAoB,CAAC;CAGvD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { accessManagerConfig } from '../artifacts/generated.js';
|
|
2
|
+
import { ContractBase } from './ContractBase.js';
|
|
3
|
+
export class AccessManager extends ContractBase {
|
|
4
|
+
static async getInstance(config) {
|
|
5
|
+
const accessManager = new AccessManager('AccessManager', accessManagerConfig.address);
|
|
6
|
+
await accessManager.init(config, accessManagerConfig);
|
|
7
|
+
return accessManager;
|
|
8
|
+
}
|
|
9
|
+
async hasRole(roleId, address) {
|
|
10
|
+
return this.contract.read.hasRole([roleId, address]);
|
|
11
|
+
}
|
|
12
|
+
async grantRole({ address, roleId, executionDelay, owner, txParams, }) {
|
|
13
|
+
return this.send('grantRole', owner, [roleId, address, executionDelay ?? 0], txParams);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CreditsConfig, CreditsType, DIDAsset, Plan, PriceConfig } from '@nvm-monorepo/commons';
|
|
2
|
+
import { Account, Address, Hex, TransactionReceipt } from 'viem';
|
|
3
|
+
import { SmartAccount, UserOperationReceipt } from 'viem/account-abstraction';
|
|
4
|
+
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
5
|
+
import { TxParameters } from '../models/Transactions.js';
|
|
6
|
+
import { ContractBase } from './ContractBase.js';
|
|
7
|
+
export declare class AssetRegistry extends ContractBase {
|
|
8
|
+
static getInstance(config: InstantiableConfig): Promise<AssetRegistry>;
|
|
9
|
+
hashDID(didSeed: string, owner: Address): Promise<string>;
|
|
10
|
+
getAsset(did: string): Promise<DIDAsset>;
|
|
11
|
+
assetExists(did: Hex): Promise<boolean>;
|
|
12
|
+
register({ didSeed, url, plans, owner, txParams, }: {
|
|
13
|
+
didSeed: string;
|
|
14
|
+
url: string;
|
|
15
|
+
plans: bigint[];
|
|
16
|
+
owner: Account | SmartAccount;
|
|
17
|
+
txParams?: TxParameters;
|
|
18
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
19
|
+
createPlan({ priceConfig, creditsConfig, owner, nonce, addFees, isTrialPlan, txParams, }: {
|
|
20
|
+
priceConfig: PriceConfig;
|
|
21
|
+
creditsConfig: CreditsConfig;
|
|
22
|
+
owner: Account | SmartAccount;
|
|
23
|
+
nonce?: bigint;
|
|
24
|
+
addFees?: boolean;
|
|
25
|
+
isTrialPlan?: boolean;
|
|
26
|
+
txParams?: TxParameters;
|
|
27
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
28
|
+
registerAssetAndPlan({ did, url, priceConfig, creditsConfig, owner, addFees, txParams, }: {
|
|
29
|
+
did: string;
|
|
30
|
+
url: string;
|
|
31
|
+
priceConfig: PriceConfig;
|
|
32
|
+
creditsConfig: CreditsConfig;
|
|
33
|
+
owner: Account | SmartAccount;
|
|
34
|
+
addFees?: boolean;
|
|
35
|
+
txParams?: TxParameters;
|
|
36
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
37
|
+
getPlan(planId: bigint): Promise<Plan>;
|
|
38
|
+
planExists(id: bigint): Promise<boolean>;
|
|
39
|
+
addPlanToAsset(planId: bigint, did: string, owner: Account | SmartAccount, txParams?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
40
|
+
removePlanFromAsset(planId: bigint, did: string, owner: Account | SmartAccount, txParams?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
41
|
+
planConfigPreFilter(priceConfig: PriceConfig, creditsConfig: CreditsConfig, addFees?: boolean): Promise<{
|
|
42
|
+
priceConfig: {
|
|
43
|
+
priceType: import("@nvm-monorepo/commons").PriceType;
|
|
44
|
+
tokenAddress?: Address;
|
|
45
|
+
amounts: bigint[];
|
|
46
|
+
receivers: string[];
|
|
47
|
+
contractAddress?: Address;
|
|
48
|
+
feeController?: Address;
|
|
49
|
+
};
|
|
50
|
+
creditsConfig: {
|
|
51
|
+
creditsType: CreditsType;
|
|
52
|
+
redemptionType: import("@nvm-monorepo/commons").RedemptionType;
|
|
53
|
+
proofRequired: boolean;
|
|
54
|
+
durationSecs: bigint;
|
|
55
|
+
amount: bigint;
|
|
56
|
+
minAmount: bigint;
|
|
57
|
+
maxAmount: bigint;
|
|
58
|
+
nftAddress?: Address;
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
hashPlanId(_priceConfig: PriceConfig, _creditsConfig: CreditsConfig, owner: Address, addFees?: boolean, nonce?: bigint): Promise<bigint>;
|
|
62
|
+
areNeverminedFeesIncluded(priceConfig: PriceConfig): Promise<boolean>;
|
|
63
|
+
addFeesToPaymentsDistribution(priceConfig: PriceConfig, creditsConfig: CreditsConfig): Promise<[bigint[], string[]]>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=AssetRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetRegistry.d.ts","sourceRoot":"","sources":["../../src/contracts/AssetRegistry.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CreditsType } from '@nvm-monorepo/commons';
|
|
2
|
+
import { isAddress } from 'viem';
|
|
3
|
+
import { assetsRegistryConfig, nft1155CreditsAddress, nft1155ExpirableCreditsAddress, oneTimeCreatorHookAddress, protocolStandardFeesAddress, } from '../artifacts/generated.js';
|
|
4
|
+
import { AssetNotFound, PlanNotFound } from '../errors/NeverminedErrors.js';
|
|
5
|
+
import { didZeroX } from '../utils/ConversionTypeHelpers.js';
|
|
6
|
+
import { ContractBase } from './ContractBase.js';
|
|
7
|
+
export class AssetRegistry extends ContractBase {
|
|
8
|
+
static async getInstance(config) {
|
|
9
|
+
const assetRegistry = new AssetRegistry('AssetRegistry', assetsRegistryConfig.address);
|
|
10
|
+
await assetRegistry.init(config, assetsRegistryConfig);
|
|
11
|
+
return assetRegistry;
|
|
12
|
+
}
|
|
13
|
+
async hashDID(didSeed, owner) {
|
|
14
|
+
return this.contract.read.hashDID([didSeed, owner]);
|
|
15
|
+
}
|
|
16
|
+
async getAsset(did) {
|
|
17
|
+
const didAsset = await this.contract.read.getAsset([did]);
|
|
18
|
+
if (didAsset.lastUpdated != 0)
|
|
19
|
+
return didAsset;
|
|
20
|
+
else
|
|
21
|
+
throw new AssetNotFound(`Asset with DID ${did} not found`);
|
|
22
|
+
}
|
|
23
|
+
async assetExists(did) {
|
|
24
|
+
return this.contract.read.assetExists([did]);
|
|
25
|
+
}
|
|
26
|
+
async register({ didSeed, url, plans, owner, txParams, }) {
|
|
27
|
+
return this.send('register', owner, [didZeroX(didSeed), url, plans], txParams);
|
|
28
|
+
}
|
|
29
|
+
async createPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, txParams, }) {
|
|
30
|
+
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees);
|
|
31
|
+
if (isTrialPlan) {
|
|
32
|
+
return this.send('createPlanWithHooks', owner, [_config.priceConfig, _config.creditsConfig, [oneTimeCreatorHookAddress], nonce], txParams);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return this.send('createPlan', owner, [_config.priceConfig, _config.creditsConfig, nonce], txParams);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async registerAssetAndPlan({ did, url, priceConfig, creditsConfig, owner, addFees = true, txParams, }) {
|
|
39
|
+
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees);
|
|
40
|
+
return this.send('registerAssetAndPlan', owner, [didZeroX(did), url, _config.priceConfig, _config.creditsConfig], txParams);
|
|
41
|
+
}
|
|
42
|
+
async getPlan(planId) {
|
|
43
|
+
const plan = this.contract.read.getPlan([planId]);
|
|
44
|
+
if (plan.lastUpdated != 0)
|
|
45
|
+
return plan;
|
|
46
|
+
else
|
|
47
|
+
throw new PlanNotFound('Plan not registered');
|
|
48
|
+
}
|
|
49
|
+
async planExists(id) {
|
|
50
|
+
return this.contract.read.planExists([id]);
|
|
51
|
+
}
|
|
52
|
+
async addPlanToAsset(planId, did, owner, txParams) {
|
|
53
|
+
return this.send('addPlanToAsset', owner, [didZeroX(did), planId], txParams);
|
|
54
|
+
}
|
|
55
|
+
async removePlanFromAsset(planId, did, owner, txParams) {
|
|
56
|
+
return this.send('removePlanFromAsset', owner, [didZeroX(did), planId], txParams);
|
|
57
|
+
}
|
|
58
|
+
async planConfigPreFilter(priceConfig, creditsConfig, addFees = true) {
|
|
59
|
+
const _priceConfig = { ...priceConfig };
|
|
60
|
+
const _creditsConfig = { ...creditsConfig };
|
|
61
|
+
console.log(protocolStandardFeesAddress);
|
|
62
|
+
if (!priceConfig.feeController || !isAddress(priceConfig.feeController))
|
|
63
|
+
_priceConfig.feeController = protocolStandardFeesAddress;
|
|
64
|
+
if (!creditsConfig.nftAddress || !isAddress(creditsConfig.nftAddress)) {
|
|
65
|
+
if (creditsConfig.creditsType === CreditsType.EXPIRABLE) {
|
|
66
|
+
_creditsConfig.nftAddress = nft1155ExpirableCreditsAddress;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
_creditsConfig.nftAddress = nft1155CreditsAddress;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (addFees) {
|
|
73
|
+
const fees = await this.addFeesToPaymentsDistribution(_priceConfig, _creditsConfig);
|
|
74
|
+
_priceConfig.amounts = fees[0];
|
|
75
|
+
_priceConfig.receivers = fees[1];
|
|
76
|
+
}
|
|
77
|
+
return { priceConfig: _priceConfig, creditsConfig: _creditsConfig };
|
|
78
|
+
}
|
|
79
|
+
async hashPlanId(_priceConfig, _creditsConfig, owner, addFees = true, nonce = 0n) {
|
|
80
|
+
const _config = await this.planConfigPreFilter(_priceConfig, _creditsConfig, addFees);
|
|
81
|
+
console.log('Price Config', _config.priceConfig);
|
|
82
|
+
console.log('Credits Config', _config.creditsConfig);
|
|
83
|
+
return await this.contract.read.hashPlanId([
|
|
84
|
+
_config.priceConfig,
|
|
85
|
+
_config.creditsConfig,
|
|
86
|
+
owner,
|
|
87
|
+
nonce,
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
async areNeverminedFeesIncluded(priceConfig) {
|
|
91
|
+
return await this.contract.read.areNeverminedFeesIncluded([
|
|
92
|
+
priceConfig.amounts,
|
|
93
|
+
priceConfig.receivers,
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
async addFeesToPaymentsDistribution(priceConfig, creditsConfig) {
|
|
97
|
+
const result = await this.contract.read.addFeesToPaymentsDistribution([
|
|
98
|
+
priceConfig,
|
|
99
|
+
creditsConfig,
|
|
100
|
+
]);
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Abi, Account, Address, TransactionReceipt } from 'viem';
|
|
2
|
+
import { SmartAccount, UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
+
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract.js';
|
|
4
|
+
import { TxParameters } from '../models/Transactions.js';
|
|
5
|
+
export declare abstract class ContractBase extends Instantiable {
|
|
6
|
+
readonly contractName: string;
|
|
7
|
+
contract: any;
|
|
8
|
+
address: Address;
|
|
9
|
+
constructor(contractName: string, address: Address);
|
|
10
|
+
protected init(config: InstantiableConfig, contractConfig: {
|
|
11
|
+
address: `0x${string}`;
|
|
12
|
+
abi: Abi;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
call<T>(functionName: string, args: any[], from?: string): Promise<T>;
|
|
15
|
+
getTransactionReceipt(txHash: UserOperationReceipt | TransactionReceipt): Promise<TransactionReceipt>;
|
|
16
|
+
getTransactionLogs(txReceipt: TransactionReceipt | UserOperationReceipt, eventName?: string): any[];
|
|
17
|
+
send(functionName: string, from: Account | SmartAccount, args: any[], params?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
18
|
+
private internalSendSmartAccount;
|
|
19
|
+
private localAccountSend;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ContractBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractBase.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractBase.ts"],"names":[],"mappings":"AACA,OAAO,EACL,GAAG,EACH,OAAO,EACP,OAAO,EAQP,kBAAkB,EACnB,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE7E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AASxD,8BAAsB,YAAa,SAAQ,YAAY;IACrD,SAAgB,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,EAAE,GAAG,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;gBAEX,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;cAMlC,IAAI,CAClB,MAAM,EAAE,kBAAkB,EAC1B,cAAc,EAAE;QAAE,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,GAAG,EAAE,GAAG,CAAA;KAAE;IAYzC,IAAI,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAiBrE,qBAAqB,CAChC,MAAM,EAAE,oBAAoB,GAAG,kBAAkB,GAChD,OAAO,CAAC,kBAAkB,CAAC;IAgBvB,kBAAkB,CACvB,SAAS,EAAE,kBAAkB,GAAG,oBAAoB,EACpD,SAAS,CAAC,EAAE,MAAM,GAOZ,GAAG,EAAE;IAGA,IAAI,CACf,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,GAAG,YAAY,EAC5B,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,kBAAkB,GAAG,oBAAoB,CAAC;YAiBvC,wBAAwB;YA8HxB,gBAAgB;CAiG/B"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { createKernelAccountClient, createZeroDevPaymasterClient } from '@zerodev/sdk';
|
|
2
|
+
import { BaseError, ContractFunctionRevertedError, encodeFunctionData, getContract, http, parseAbi, parseEventLogs, } from 'viem';
|
|
3
|
+
import { ContractsError } from '../errors/index.js';
|
|
4
|
+
import { Instantiable } from '../Instantiable.abstract.js';
|
|
5
|
+
import { getInputsOfFunctionFormatted, getSignatureOfFunction, getTransactionReceipt, } from '../nevermined/index.js';
|
|
6
|
+
import { jsonReplacer } from '../utils/helpers.js';
|
|
7
|
+
import { getChain } from '../utils/Network.js';
|
|
8
|
+
export class ContractBase extends Instantiable {
|
|
9
|
+
contractName;
|
|
10
|
+
contract;
|
|
11
|
+
address;
|
|
12
|
+
constructor(contractName, address) {
|
|
13
|
+
super();
|
|
14
|
+
this.contractName = contractName;
|
|
15
|
+
this.address = address;
|
|
16
|
+
}
|
|
17
|
+
async init(config, contractConfig) {
|
|
18
|
+
this.setInstanceConfig(config);
|
|
19
|
+
this.address = contractConfig.address;
|
|
20
|
+
this.contract = getContract({
|
|
21
|
+
address: contractConfig.address,
|
|
22
|
+
abi: contractConfig.abi,
|
|
23
|
+
client: { public: this.publicClient, wallet: this.walletClient },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async call(functionName, args, from) {
|
|
27
|
+
try {
|
|
28
|
+
return (await this.client.public.readContract({
|
|
29
|
+
address: this.address,
|
|
30
|
+
abi: this.contract.abi,
|
|
31
|
+
functionName: parseAbi([functionName]),
|
|
32
|
+
args,
|
|
33
|
+
...(from && { account: from }),
|
|
34
|
+
}));
|
|
35
|
+
//return await this.contract[functionSignature](...args, { from })
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw new ContractsError(`Calling method "${functionName}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async getTransactionReceipt(txHash) {
|
|
42
|
+
// Get the transaction receipt depending on the type of txHash
|
|
43
|
+
if ('transactionHash' in txHash) {
|
|
44
|
+
// txHash is TransactionReceipt
|
|
45
|
+
return txHash;
|
|
46
|
+
}
|
|
47
|
+
else if ('userOpHash' in txHash) {
|
|
48
|
+
// txHash is UserOperationReceipt, fetch the actual receipt
|
|
49
|
+
// return txHash.receipt
|
|
50
|
+
return this.client.public.getTransactionReceipt({
|
|
51
|
+
hash: txHash.receipt.transactionHash,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error('Unknown transaction type');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
getTransactionLogs(txReceipt, eventName) {
|
|
59
|
+
return parseEventLogs({
|
|
60
|
+
abi: this.contract.abi,
|
|
61
|
+
logs: txReceipt.logs,
|
|
62
|
+
eventName,
|
|
63
|
+
strict: false,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async send(functionName, from, args, params = {}) {
|
|
67
|
+
if (from.type === 'local') {
|
|
68
|
+
this.logger.debug(`Blockchain Send using Local account with functionName: ${functionName} and following args: ${args}`);
|
|
69
|
+
return await this.localAccountSend(functionName, from, args, params, params.progress);
|
|
70
|
+
}
|
|
71
|
+
else if (from.type === 'json-rpc') {
|
|
72
|
+
this.logger.debug(`Blockchain Send using JSON-RPC account to ${functionName}`);
|
|
73
|
+
return await this.localAccountSend(functionName, from, args, params, params.progress);
|
|
74
|
+
}
|
|
75
|
+
else if (from.type === 'smart') {
|
|
76
|
+
this.logger.debug(`Blockchain Send using ZeroDev account`);
|
|
77
|
+
return await this.internalSendSmartAccount(functionName, from, args, params, params.progress);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new ContractsError(`Account not supported`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async internalSendSmartAccount(name, from, args, txparams, progress) {
|
|
84
|
+
const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args);
|
|
85
|
+
const { gasLimit, value } = txparams;
|
|
86
|
+
if (progress) {
|
|
87
|
+
progress({
|
|
88
|
+
stage: 'sending',
|
|
89
|
+
args: functionInputs,
|
|
90
|
+
method: name,
|
|
91
|
+
from: from,
|
|
92
|
+
value,
|
|
93
|
+
contractName: this.contractName,
|
|
94
|
+
contractAddress: this.address,
|
|
95
|
+
gasLimit,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const ZERODEV_RPC = `https://rpc.zerodev.app/api/v3/${this.config.zeroDevProjectId}/chain/${this.config.chainId}`;
|
|
99
|
+
try {
|
|
100
|
+
await this.client.public.simulateContract({
|
|
101
|
+
address: this.address,
|
|
102
|
+
abi: this.contract.abi,
|
|
103
|
+
functionName: name,
|
|
104
|
+
args,
|
|
105
|
+
account: from,
|
|
106
|
+
...(txparams.value && { value: txparams.value }),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
if (err instanceof BaseError) {
|
|
111
|
+
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
112
|
+
this.logger.error('revertError', revertError);
|
|
113
|
+
}
|
|
114
|
+
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
115
|
+
}
|
|
116
|
+
const zerodevPaymaster = createZeroDevPaymasterClient({
|
|
117
|
+
chain: getChain(this.config.chainId),
|
|
118
|
+
transport: http(ZERODEV_RPC),
|
|
119
|
+
});
|
|
120
|
+
const kernelClient = createKernelAccountClient({
|
|
121
|
+
account: from,
|
|
122
|
+
// Replace with your chain
|
|
123
|
+
chain: getChain(this.config.chainId),
|
|
124
|
+
// Find the RPC in your ZeroDev dashboard
|
|
125
|
+
bundlerTransport: http(ZERODEV_RPC),
|
|
126
|
+
// Required - the public client
|
|
127
|
+
client: this.contract.publicClient,
|
|
128
|
+
// Optional -- only if you want to use a paymaster
|
|
129
|
+
paymaster: {
|
|
130
|
+
getPaymasterData: (userOperation) => {
|
|
131
|
+
return zerodevPaymaster.sponsorUserOperation({
|
|
132
|
+
userOperation,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const data = encodeFunctionData({ abi: this.contract.abi, functionName: name, args });
|
|
138
|
+
let userOpHash;
|
|
139
|
+
try {
|
|
140
|
+
userOpHash = await kernelClient.sendUserOperation({
|
|
141
|
+
callData: await kernelClient.account.encodeCalls([
|
|
142
|
+
{
|
|
143
|
+
to: this.address,
|
|
144
|
+
value: txparams.value || 0n,
|
|
145
|
+
data,
|
|
146
|
+
},
|
|
147
|
+
]),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (err instanceof BaseError) {
|
|
152
|
+
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
153
|
+
this.logger.error('revertError', revertError);
|
|
154
|
+
}
|
|
155
|
+
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
156
|
+
}
|
|
157
|
+
if (progress) {
|
|
158
|
+
progress({
|
|
159
|
+
stage: 'sent',
|
|
160
|
+
args: functionInputs,
|
|
161
|
+
userOpHash,
|
|
162
|
+
method: name,
|
|
163
|
+
from: from,
|
|
164
|
+
value,
|
|
165
|
+
contractName: this.contractName,
|
|
166
|
+
contractAddress: this.address,
|
|
167
|
+
gasLimit,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const txReceipt = await kernelClient.waitForUserOperationReceipt({ hash: userOpHash });
|
|
171
|
+
if (progress) {
|
|
172
|
+
progress({
|
|
173
|
+
stage: 'receipt',
|
|
174
|
+
args: functionInputs,
|
|
175
|
+
txReceipt,
|
|
176
|
+
method: name,
|
|
177
|
+
from: from,
|
|
178
|
+
value,
|
|
179
|
+
contractName: this.contractName,
|
|
180
|
+
contractAddress: this.address,
|
|
181
|
+
gasLimit,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return txReceipt;
|
|
185
|
+
}
|
|
186
|
+
async localAccountSend(name, from, args, txparams, progress) {
|
|
187
|
+
const functionInputs = getInputsOfFunctionFormatted(this.contract.abi, name, args);
|
|
188
|
+
// Uncomment to debug contract calls
|
|
189
|
+
if (name === 'createAgreement') {
|
|
190
|
+
const functionSignature = getSignatureOfFunction(this.contract.abi, name, args);
|
|
191
|
+
console.debug(`Making contract call ....: ${name} - ${from}`);
|
|
192
|
+
console.debug(`With args`, args);
|
|
193
|
+
console.debug(`And signature - ${JSON.stringify(functionSignature, jsonReplacer)}`);
|
|
194
|
+
console.debug('And amount: ', txparams.value);
|
|
195
|
+
}
|
|
196
|
+
// abi.filter(({name, inputs}) => name === 'closeSignals' && inputs.length === 1)
|
|
197
|
+
// const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.inputs.length === args.length)
|
|
198
|
+
// const abiFilter = this.contract.abi.filter((abi) => abi.name === name && abi.type === 'function')
|
|
199
|
+
// console.debug('abi', this.contract.abi.filter((abi) => abi.name === name))
|
|
200
|
+
// console.debug('abiFilter', abiFilter)
|
|
201
|
+
// if (!abiFilter)
|
|
202
|
+
// throw new ContractsError(
|
|
203
|
+
// `No ABI found for method "${name}" with ${args.length} arguments on contract "${this.contractName}"`,
|
|
204
|
+
// )
|
|
205
|
+
const { gasLimit, value } = txparams;
|
|
206
|
+
// make the call
|
|
207
|
+
if (progress) {
|
|
208
|
+
progress({
|
|
209
|
+
stage: 'sending',
|
|
210
|
+
args: functionInputs,
|
|
211
|
+
method: name,
|
|
212
|
+
from,
|
|
213
|
+
value,
|
|
214
|
+
contractName: this.contractName,
|
|
215
|
+
contractAddress: this.address,
|
|
216
|
+
gasLimit,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
let txHash;
|
|
220
|
+
try {
|
|
221
|
+
const { request } = await this.client.public.simulateContract({
|
|
222
|
+
address: this.address,
|
|
223
|
+
abi: this.contract.abi,
|
|
224
|
+
functionName: name,
|
|
225
|
+
args,
|
|
226
|
+
account: from,
|
|
227
|
+
...(txparams.value && { value: txparams.value }),
|
|
228
|
+
});
|
|
229
|
+
txHash = await this.client.wallet.writeContract({
|
|
230
|
+
...request,
|
|
231
|
+
account: from,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
if (err instanceof BaseError) {
|
|
236
|
+
const revertError = err.walk((err) => err instanceof ContractFunctionRevertedError);
|
|
237
|
+
this.logger.error('revertError', revertError);
|
|
238
|
+
}
|
|
239
|
+
throw new ContractsError(`Calling method "${name}" on contract "${this.contractName}" failed. Args: ${args} - ${err}`);
|
|
240
|
+
}
|
|
241
|
+
if (progress) {
|
|
242
|
+
progress({
|
|
243
|
+
stage: 'sent',
|
|
244
|
+
args: functionInputs,
|
|
245
|
+
txHash,
|
|
246
|
+
method: name,
|
|
247
|
+
from,
|
|
248
|
+
value,
|
|
249
|
+
contractName: this.contractName,
|
|
250
|
+
contractAddress: this.address,
|
|
251
|
+
gasLimit,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const txReceipt = getTransactionReceipt({ txHash, publicClient: this.client.public });
|
|
255
|
+
if (progress) {
|
|
256
|
+
progress({
|
|
257
|
+
stage: 'receipt',
|
|
258
|
+
args: functionInputs,
|
|
259
|
+
txReceipt,
|
|
260
|
+
method: name,
|
|
261
|
+
from,
|
|
262
|
+
value,
|
|
263
|
+
contractName: this.contractName,
|
|
264
|
+
contractAddress: this.address,
|
|
265
|
+
gasLimit,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return txReceipt;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract.js';
|
|
2
|
+
import { AccessManager } from './AccessManager.js';
|
|
3
|
+
import { AssetRegistry } from './AssetRegistry.js';
|
|
4
|
+
import { FiatPaymentTemplate } from './FiatPaymentTemplate.js';
|
|
5
|
+
import { FixedPaymentTemplate } from './FixedPaymentTemplate.js';
|
|
6
|
+
import { NFT1155Credits } from './NFT1155Credits.js';
|
|
7
|
+
import { NFT1155ExpirableCredits } from './NFT1155ExpirableCredits.js';
|
|
8
|
+
import { NeverminedConfig } from './NVMConfig.js';
|
|
9
|
+
import { ProtocolStandardFees } from './ProtocolStandardFees.js';
|
|
10
|
+
export declare class ContractsApi extends Instantiable {
|
|
11
|
+
/**
|
|
12
|
+
* Return ContractsApi instance
|
|
13
|
+
* @param config
|
|
14
|
+
* @returns {@link ContractsApi}
|
|
15
|
+
*/
|
|
16
|
+
static getInstance(config: InstantiableConfig): Promise<ContractsApi>;
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Access Manager smart contract instance.
|
|
20
|
+
*/
|
|
21
|
+
accessManager: AccessManager;
|
|
22
|
+
/**
|
|
23
|
+
* Nevermined Config smart contract instance.
|
|
24
|
+
*/
|
|
25
|
+
nvmConfig: NeverminedConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Asset registry smart contract instance.
|
|
28
|
+
*/
|
|
29
|
+
assetRegistry: AssetRegistry;
|
|
30
|
+
/**
|
|
31
|
+
* NFT1155Credits smart contract instance.
|
|
32
|
+
* Manages non-expirable credits using the ERC-1155 standard.
|
|
33
|
+
* Allows minting, burning and balance checking of credits.
|
|
34
|
+
*/
|
|
35
|
+
nft1155Credits: NFT1155Credits;
|
|
36
|
+
/**
|
|
37
|
+
* NFT1155ExpirableCredits smart contract instance.
|
|
38
|
+
* Manages expirable credits using the ERC-1155 standard.
|
|
39
|
+
* Similar to NFT1155Credits but with an additional expiration mechanism.
|
|
40
|
+
* Credits minted through this contract will expire after a specified duration.
|
|
41
|
+
*/
|
|
42
|
+
nft1155ExpirableCredits: NFT1155ExpirableCredits;
|
|
43
|
+
/**
|
|
44
|
+
* FixedPaymentTemplate smart contract instance.
|
|
45
|
+
* Handles fixed payment agreements between parties.
|
|
46
|
+
* Used for creating and managing payment agreements with predefined terms.
|
|
47
|
+
*/
|
|
48
|
+
fixedPaymentTemplate: FixedPaymentTemplate;
|
|
49
|
+
/**
|
|
50
|
+
* FiatPaymentTemplate smart contract instance.
|
|
51
|
+
* Handles fiat payment agreements between parties (i.e Stripe).
|
|
52
|
+
* Used for creating and managing payment agreements with predefined terms.
|
|
53
|
+
*/
|
|
54
|
+
fiatPaymentTemplate: FiatPaymentTemplate;
|
|
55
|
+
/**
|
|
56
|
+
* ProtocolStandardFees smart contract instance.
|
|
57
|
+
* It provides methods to calculate fees based on total amounts, price configurations, and credits configurations.
|
|
58
|
+
* This is the default fee controller for the protocol.
|
|
59
|
+
*/
|
|
60
|
+
protocolStandardFees: ProtocolStandardFees;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ContractsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractsApi.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,qBAAa,YAAa,SAAQ,YAAY;IAC5C;;;;OAIG;WAC0B,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IAM9E,IAAI;IA0BjB;;OAEG;IACI,aAAa,EAAG,aAAa,CAAA;IACpC;;OAEG;IACI,SAAS,EAAG,gBAAgB,CAAA;IAEnC;;OAEG;IACI,aAAa,EAAG,aAAa,CAAA;IAEpC;;;;OAIG;IACI,cAAc,EAAG,cAAc,CAAA;IAEtC;;;;;OAKG;IACI,uBAAuB,EAAG,uBAAuB,CAAA;IAExD;;;;OAIG;IACI,oBAAoB,EAAG,oBAAoB,CAAA;IAElD;;;;OAIG;IACI,mBAAmB,EAAG,mBAAmB,CAAA;IAEhD;;;;OAIG;IACI,oBAAoB,EAAG,oBAAoB,CAAA;CACnD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Instantiable } from '../Instantiable.abstract.js';
|
|
2
|
+
export class ContractsApi extends Instantiable {
|
|
3
|
+
/**
|
|
4
|
+
* Return ContractsApi instance
|
|
5
|
+
* @param config
|
|
6
|
+
* @returns {@link ContractsApi}
|
|
7
|
+
*/
|
|
8
|
+
static async getInstance(config) {
|
|
9
|
+
const contractsApi = new ContractsApi();
|
|
10
|
+
contractsApi.setInstanceConfig(config);
|
|
11
|
+
return contractsApi;
|
|
12
|
+
}
|
|
13
|
+
async init() {
|
|
14
|
+
this.accessManager = await (await import('./AccessManager.js')).AccessManager.getInstance(this.instanceConfig);
|
|
15
|
+
this.nvmConfig = await (await import('./NVMConfig.js')).NeverminedConfig.getInstance(this.instanceConfig);
|
|
16
|
+
this.assetRegistry = await (await import('./AssetRegistry.js')).AssetRegistry.getInstance(this.instanceConfig);
|
|
17
|
+
this.nft1155Credits = await (await import('./NFT1155Credits.js')).NFT1155Credits.getInstance(this.instanceConfig);
|
|
18
|
+
this.nft1155ExpirableCredits = await (await import('./NFT1155ExpirableCredits.js')).NFT1155ExpirableCredits.getInstance(this.instanceConfig);
|
|
19
|
+
this.fixedPaymentTemplate = await (await import('./FixedPaymentTemplate.js')).FixedPaymentTemplate.getInstance(this.instanceConfig);
|
|
20
|
+
this.fiatPaymentTemplate = await (await import('./FiatPaymentTemplate.js')).FiatPaymentTemplate.getInstance(this.instanceConfig);
|
|
21
|
+
this.protocolStandardFees = await (await import('./ProtocolStandardFees.js')).ProtocolStandardFees.getInstance(this.instanceConfig);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Access Manager smart contract instance.
|
|
25
|
+
*/
|
|
26
|
+
accessManager;
|
|
27
|
+
/**
|
|
28
|
+
* Nevermined Config smart contract instance.
|
|
29
|
+
*/
|
|
30
|
+
nvmConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Asset registry smart contract instance.
|
|
33
|
+
*/
|
|
34
|
+
assetRegistry;
|
|
35
|
+
/**
|
|
36
|
+
* NFT1155Credits smart contract instance.
|
|
37
|
+
* Manages non-expirable credits using the ERC-1155 standard.
|
|
38
|
+
* Allows minting, burning and balance checking of credits.
|
|
39
|
+
*/
|
|
40
|
+
nft1155Credits;
|
|
41
|
+
/**
|
|
42
|
+
* NFT1155ExpirableCredits smart contract instance.
|
|
43
|
+
* Manages expirable credits using the ERC-1155 standard.
|
|
44
|
+
* Similar to NFT1155Credits but with an additional expiration mechanism.
|
|
45
|
+
* Credits minted through this contract will expire after a specified duration.
|
|
46
|
+
*/
|
|
47
|
+
nft1155ExpirableCredits;
|
|
48
|
+
/**
|
|
49
|
+
* FixedPaymentTemplate smart contract instance.
|
|
50
|
+
* Handles fixed payment agreements between parties.
|
|
51
|
+
* Used for creating and managing payment agreements with predefined terms.
|
|
52
|
+
*/
|
|
53
|
+
fixedPaymentTemplate;
|
|
54
|
+
/**
|
|
55
|
+
* FiatPaymentTemplate smart contract instance.
|
|
56
|
+
* Handles fiat payment agreements between parties (i.e Stripe).
|
|
57
|
+
* Used for creating and managing payment agreements with predefined terms.
|
|
58
|
+
*/
|
|
59
|
+
fiatPaymentTemplate;
|
|
60
|
+
/**
|
|
61
|
+
* ProtocolStandardFees smart contract instance.
|
|
62
|
+
* It provides methods to calculate fees based on total amounts, price configurations, and credits configurations.
|
|
63
|
+
* This is the default fee controller for the protocol.
|
|
64
|
+
*/
|
|
65
|
+
protocolStandardFees;
|
|
66
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Account, Address } from 'viem';
|
|
2
|
+
import { SmartAccount } from 'viem/account-abstraction';
|
|
3
|
+
import { InstantiableConfig } from '../Instantiable.abstract.js';
|
|
4
|
+
import { TxParameters } from '../models/Transactions.js';
|
|
5
|
+
import { ContractBase } from './ContractBase.js';
|
|
6
|
+
export declare class FiatPaymentTemplate extends ContractBase {
|
|
7
|
+
static getInstance(config: InstantiableConfig): Promise<FiatPaymentTemplate>;
|
|
8
|
+
createAgreement(planId: bigint, creditsReceiver: Address, owner: Account | SmartAccount, txParams?: TxParameters): Promise<import("viem").TransactionReceipt | import("viem/account-abstraction").UserOperationReceipt>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=FiatPaymentTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FiatPaymentTemplate.d.ts","sourceRoot":"","sources":["../../src/contracts/FiatPaymentTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,qBAAa,mBAAoB,SAAQ,YAAY;WACtB,WAAW,CACtC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC;IASlB,eAAe,CAC1B,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,OAAO,EACxB,KAAK,EAAE,OAAO,GAAG,YAAY,EAC7B,QAAQ,CAAC,EAAE,YAAY;CAU1B"}
|