@nevermined-io/core-kit 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Instantiable.abstract.d.ts +33 -0
- package/dist/Instantiable.abstract.d.ts.map +1 -0
- package/dist/Instantiable.abstract.js +98 -0
- package/dist/artifacts/generated.d.ts +39371 -0
- package/dist/artifacts/generated.d.ts.map +1 -0
- package/dist/artifacts/generated.js +21448 -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 +105 -0
- package/dist/contracts/AssetRegistry.d.ts.map +1 -0
- package/dist/contracts/AssetRegistry.js +155 -0
- package/dist/contracts/ContractBase.d.ts +45 -0
- package/dist/contracts/ContractBase.d.ts.map +1 -0
- package/dist/contracts/ContractBase.js +519 -0
- package/dist/contracts/ContractsApi.d.ts +69 -0
- package/dist/contracts/ContractsApi.d.ts.map +1 -0
- package/dist/contracts/ContractsApi.js +73 -0
- package/dist/contracts/CryptoTemplateBase.d.ts +11 -0
- package/dist/contracts/CryptoTemplateBase.d.ts.map +1 -0
- package/dist/contracts/CryptoTemplateBase.js +49 -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 +12 -0
- package/dist/contracts/FixedPaymentTemplate.d.ts.map +1 -0
- package/dist/contracts/FixedPaymentTemplate.js +62 -0
- package/dist/contracts/NFT1155Base.d.ts +50 -0
- package/dist/contracts/NFT1155Base.d.ts.map +1 -0
- package/dist/contracts/NFT1155Base.js +24 -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/PayAsYouGoTemplate.d.ts +12 -0
- package/dist/contracts/PayAsYouGoTemplate.d.ts.map +1 -0
- package/dist/contracts/PayAsYouGoTemplate.js +62 -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 +74 -0
- package/dist/errors/NeverminedErrors.d.ts.map +1 -0
- package/dist/errors/NeverminedErrors.js +128 -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 +8 -0
- package/dist/models/AgentAccessToken.d.ts +123 -0
- package/dist/models/AgentAccessToken.d.ts.map +1 -0
- package/dist/models/AgentAccessToken.js +164 -0
- package/dist/models/AgentX402AccessToken.d.ts +59 -0
- package/dist/models/AgentX402AccessToken.d.ts.map +1 -0
- package/dist/models/AgentX402AccessToken.js +78 -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 +30 -0
- package/dist/models/NeverminedOptions.d.ts.map +1 -0
- package/dist/models/NeverminedOptions.js +28 -0
- package/dist/models/NvmApiKey.d.ts +137 -0
- package/dist/models/NvmApiKey.d.ts.map +1 -0
- package/dist/models/NvmApiKey.js +235 -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 +7 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +6 -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 +24 -0
- package/dist/nevermined/api/PaymentsApi.d.ts.map +1 -0
- package/dist/nevermined/api/PaymentsApi.js +179 -0
- package/dist/nevermined/api/ServicesApi.d.ts +23 -0
- package/dist/nevermined/api/ServicesApi.d.ts.map +1 -0
- package/dist/nevermined/api/ServicesApi.js +27 -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 +3 -0
- package/dist/nevermined/index.d.ts.map +1 -0
- package/dist/nevermined/index.js +2 -0
- package/dist/nevermined/utils/AgentUtils.d.ts +8 -0
- package/dist/nevermined/utils/AgentUtils.d.ts.map +1 -0
- package/dist/nevermined/utils/AgentUtils.js +56 -0
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +280 -0
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +1 -0
- package/dist/nevermined/utils/BlockchainViemUtils.js +408 -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 +161 -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 +30 -0
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +1 -0
- package/dist/nevermined/utils/WebServiceConnector.js +170 -0
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts +38 -0
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +1 -0
- package/dist/nevermined/utils/ZeroDevPolicies.js +196 -0
- package/dist/nevermined/utils/index.d.ts +7 -0
- package/dist/nevermined/utils/index.d.ts.map +1 -0
- package/dist/nevermined/utils/index.js +6 -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/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 +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +2 -0
- package/dist/utils/ConversionTypeHelpers.d.ts +5 -0
- package/dist/utils/ConversionTypeHelpers.d.ts.map +1 -0
- package/dist/utils/ConversionTypeHelpers.js +30 -0
- package/dist/utils/DeploymentInfo.d.ts +15 -0
- package/dist/utils/DeploymentInfo.d.ts.map +1 -0
- package/dist/utils/DeploymentInfo.js +38 -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 +40 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +189 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/package.json +3 -3
|
@@ -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,105 @@
|
|
|
1
|
+
import { CreditsConfig, DIDAgent, Plan, PriceConfig } from '@nvm-monorepo/commons';
|
|
2
|
+
import { Account, Address, 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
|
+
hashAgentId(seed: string, owner: Address): Promise<bigint>;
|
|
10
|
+
getAgent(agentId: string | bigint): Promise<DIDAgent>;
|
|
11
|
+
register({ seed, url, plans, owner, txParams, }: {
|
|
12
|
+
seed: string;
|
|
13
|
+
url: string;
|
|
14
|
+
plans: bigint[];
|
|
15
|
+
owner: Account | SmartAccount;
|
|
16
|
+
txParams?: TxParameters;
|
|
17
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
18
|
+
createPayAsYouGoPlan({ priceConfig, creditsConfig, owner, nonce, addFees, isTrialPlan, organizationCryptoFee, organizationCryptoWallet, txParams, }: {
|
|
19
|
+
priceConfig: PriceConfig;
|
|
20
|
+
creditsConfig: CreditsConfig;
|
|
21
|
+
owner: Account | SmartAccount;
|
|
22
|
+
nonce?: bigint;
|
|
23
|
+
addFees?: boolean;
|
|
24
|
+
isTrialPlan?: boolean;
|
|
25
|
+
organizationCryptoFee?: bigint;
|
|
26
|
+
organizationCryptoWallet?: string;
|
|
27
|
+
txParams?: TxParameters;
|
|
28
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
29
|
+
createPlan({ priceConfig, creditsConfig, owner, nonce, addFees, isTrialPlan, organizationCryptoFee, organizationCryptoWallet, txParams, }: {
|
|
30
|
+
priceConfig: PriceConfig;
|
|
31
|
+
creditsConfig: CreditsConfig;
|
|
32
|
+
owner: Account | SmartAccount;
|
|
33
|
+
nonce?: bigint;
|
|
34
|
+
addFees?: boolean;
|
|
35
|
+
isTrialPlan?: boolean;
|
|
36
|
+
organizationCryptoFee?: bigint;
|
|
37
|
+
organizationCryptoWallet?: string;
|
|
38
|
+
txParams?: TxParameters;
|
|
39
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
40
|
+
registerAgentAndPlan({ seed, url, priceConfig, creditsConfig, owner, addFees, organizationCryptoFee, organizationCryptoWallet, txParams, }: {
|
|
41
|
+
seed: string;
|
|
42
|
+
url: string;
|
|
43
|
+
priceConfig: PriceConfig;
|
|
44
|
+
creditsConfig: CreditsConfig;
|
|
45
|
+
owner: Account | SmartAccount;
|
|
46
|
+
addFees?: boolean;
|
|
47
|
+
organizationCryptoFee?: bigint;
|
|
48
|
+
organizationCryptoWallet?: string;
|
|
49
|
+
txParams?: TxParameters;
|
|
50
|
+
}): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
51
|
+
getPlan(planId: bigint): Promise<Plan>;
|
|
52
|
+
getPlanTotalPrice({ planId, plan, }: {
|
|
53
|
+
planId?: bigint;
|
|
54
|
+
plan?: Plan;
|
|
55
|
+
}): Promise<bigint>;
|
|
56
|
+
planExists(id: bigint): Promise<boolean>;
|
|
57
|
+
addPlanToAgent(planId: bigint, agentId: string | bigint, owner: Account | SmartAccount, txParams?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
58
|
+
removePlanFromAgent(planId: bigint, agentId: string | bigint, owner: Account | SmartAccount, txParams?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
59
|
+
planConfigPreFilter(priceConfig: PriceConfig, creditsConfig: CreditsConfig, includeFees?: boolean, organizationCryptoFee?: bigint, organizationCryptoWallet?: string): Promise<{
|
|
60
|
+
priceConfig: {
|
|
61
|
+
isCrypto: boolean;
|
|
62
|
+
tokenAddress?: Address;
|
|
63
|
+
amounts: bigint[];
|
|
64
|
+
receivers: string[];
|
|
65
|
+
externalPriceAddress?: Address;
|
|
66
|
+
feeController?: Address;
|
|
67
|
+
templateAddress?: Address;
|
|
68
|
+
};
|
|
69
|
+
creditsConfig: {
|
|
70
|
+
isRedemptionAmountFixed: boolean;
|
|
71
|
+
redemptionType: import("@nvm-monorepo/commons").RedemptionType;
|
|
72
|
+
proofRequired: boolean;
|
|
73
|
+
durationSecs: bigint;
|
|
74
|
+
amount: bigint;
|
|
75
|
+
minAmount: bigint;
|
|
76
|
+
maxAmount: bigint;
|
|
77
|
+
nftAddress?: Address;
|
|
78
|
+
};
|
|
79
|
+
}>;
|
|
80
|
+
hashPlanId(_priceConfig: PriceConfig, _creditsConfig: CreditsConfig, owner: Address, addFees?: boolean, nonce?: bigint, organizationCryptoFee?: bigint, organizationCryptoWallet?: string): Promise<bigint>;
|
|
81
|
+
/**
|
|
82
|
+
* @notice Checks if Nevermined fees are included in the payment distribution
|
|
83
|
+
* @param _planId The ID of the plan to check
|
|
84
|
+
* @return bool True if Nevermined fees are properly included
|
|
85
|
+
*/
|
|
86
|
+
areNeverminedFeesIncluded(priceConfig: PriceConfig): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* @notice Getting a payment distribution, it includes the Nevermined fees if not already included
|
|
89
|
+
* This method subsctracts the fees from the original amounts and adds a new entry for the fee recipient
|
|
90
|
+
* @param priceConfig The price configuration of the plan
|
|
91
|
+
* @param creditsConfig The credits configuration of the plan
|
|
92
|
+
* @return amounts Updated array of payment amounts including fees
|
|
93
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
94
|
+
*/
|
|
95
|
+
includeFeesInPaymentsDistribution(priceConfig: PriceConfig, creditsConfig: CreditsConfig): Promise<[bigint[], string[]]>;
|
|
96
|
+
/**
|
|
97
|
+
* @notice Adds Nevermined fees to the payment distribution if not already included
|
|
98
|
+
* @param priceConfig The price configuration of the plan
|
|
99
|
+
* @param creditsConfig The credits configuration of the plan
|
|
100
|
+
* @return amounts Updated array of payment amounts including fees
|
|
101
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
102
|
+
*/
|
|
103
|
+
addFeesToPaymentsDistribution(priceConfig: PriceConfig, creditsConfig: CreditsConfig): Promise<[bigint[], string[]]>;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=AssetRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetRegistry.d.ts","sourceRoot":"","sources":["../../src/contracts/AssetRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAa,kBAAkB,EAAe,MAAM,MAAM,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,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CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;CAOjC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { isAddress, zeroAddress } from 'viem';
|
|
2
|
+
import { assetsRegistryConfig, nft1155CreditsAddress, nft1155ExpirableCreditsV2Address, oneTimeCreatorHookAddress, payAsYouGoTemplateAddress, protocolStandardFeesAddress, } from '../artifacts/generated.js';
|
|
3
|
+
import { AgentNotFound, PlanNotFound } from '../errors/NeverminedErrors.js';
|
|
4
|
+
import { zeroX, toAgentId } from '../utils/ConversionTypeHelpers.js';
|
|
5
|
+
import { ContractBase } from './ContractBase.js';
|
|
6
|
+
export class AssetRegistry extends ContractBase {
|
|
7
|
+
static async getInstance(config) {
|
|
8
|
+
const assetRegistry = new AssetRegistry('AssetRegistry', assetsRegistryConfig.address);
|
|
9
|
+
await assetRegistry.init(config, assetsRegistryConfig);
|
|
10
|
+
return assetRegistry;
|
|
11
|
+
}
|
|
12
|
+
async hashAgentId(seed, owner) {
|
|
13
|
+
return this.contract.read.hashAgentId([seed, owner]);
|
|
14
|
+
}
|
|
15
|
+
async getAgent(agentId) {
|
|
16
|
+
const didAgent = await this.contract.read.getAgent([toAgentId(agentId)]);
|
|
17
|
+
if (didAgent.lastUpdated != 0)
|
|
18
|
+
return didAgent;
|
|
19
|
+
else
|
|
20
|
+
throw new AgentNotFound(`Agent with id ${agentId} not found`);
|
|
21
|
+
}
|
|
22
|
+
async register({ seed, url, plans, owner, txParams, }) {
|
|
23
|
+
return this.send('register', owner, [zeroX(seed), url, plans], txParams);
|
|
24
|
+
}
|
|
25
|
+
async createPayAsYouGoPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams, }) {
|
|
26
|
+
priceConfig.templateAddress = payAsYouGoTemplateAddress;
|
|
27
|
+
return this.createPlan({
|
|
28
|
+
priceConfig,
|
|
29
|
+
creditsConfig,
|
|
30
|
+
owner,
|
|
31
|
+
nonce,
|
|
32
|
+
addFees,
|
|
33
|
+
isTrialPlan,
|
|
34
|
+
organizationCryptoFee,
|
|
35
|
+
organizationCryptoWallet,
|
|
36
|
+
txParams,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async createPlan({ priceConfig, creditsConfig, owner, nonce = 0n, addFees = true, isTrialPlan = false, organizationCryptoFee, organizationCryptoWallet, txParams, }) {
|
|
40
|
+
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
41
|
+
if (isTrialPlan) {
|
|
42
|
+
const hooks = [oneTimeCreatorHookAddress];
|
|
43
|
+
return this.send('createPlanWithHooks', owner, [_config.priceConfig, _config.creditsConfig, hooks, nonce], txParams);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return this.send('createPlan', owner, [_config.priceConfig, _config.creditsConfig, nonce], txParams);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async registerAgentAndPlan({ seed, url, priceConfig, creditsConfig, owner, addFees = true, organizationCryptoFee, organizationCryptoWallet, txParams, }) {
|
|
50
|
+
const _config = await this.planConfigPreFilter(priceConfig, creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
51
|
+
return this.send('registerAgentAndPlan', owner, [zeroX(seed), url, _config.priceConfig, _config.creditsConfig], txParams);
|
|
52
|
+
}
|
|
53
|
+
async getPlan(planId) {
|
|
54
|
+
const plan = this.contract.read.getPlan([planId]);
|
|
55
|
+
if (plan.lastUpdated != 0)
|
|
56
|
+
return plan;
|
|
57
|
+
else
|
|
58
|
+
throw new PlanNotFound('Plan not registered');
|
|
59
|
+
}
|
|
60
|
+
async getPlanTotalPrice({ planId, plan, }) {
|
|
61
|
+
if (!plan && !planId) {
|
|
62
|
+
throw new PlanNotFound('Plan not registered');
|
|
63
|
+
}
|
|
64
|
+
if (!plan) {
|
|
65
|
+
plan = await this.getPlan(planId);
|
|
66
|
+
}
|
|
67
|
+
if (plan.lastUpdated === 0n)
|
|
68
|
+
throw new PlanNotFound('Plan not registered');
|
|
69
|
+
return plan.price.amounts.reduce((a, b) => a + b, 0n);
|
|
70
|
+
}
|
|
71
|
+
async planExists(id) {
|
|
72
|
+
return this.contract.read.planExists([id]);
|
|
73
|
+
}
|
|
74
|
+
async addPlanToAgent(planId, agentId, owner, txParams) {
|
|
75
|
+
return this.send('addPlanToAgent', owner, [toAgentId(agentId), planId], txParams);
|
|
76
|
+
}
|
|
77
|
+
async removePlanFromAgent(planId, agentId, owner, txParams) {
|
|
78
|
+
return this.send('removePlanFromAgent', owner, [toAgentId(agentId), planId], txParams);
|
|
79
|
+
}
|
|
80
|
+
async planConfigPreFilter(priceConfig, creditsConfig, includeFees = true, organizationCryptoFee, organizationCryptoWallet) {
|
|
81
|
+
const _priceConfig = { ...priceConfig };
|
|
82
|
+
const _creditsConfig = { ...creditsConfig };
|
|
83
|
+
if (!priceConfig.feeController || !isAddress(priceConfig.feeController))
|
|
84
|
+
_priceConfig.feeController = protocolStandardFeesAddress;
|
|
85
|
+
if (!priceConfig.templateAddress || !isAddress(priceConfig.templateAddress))
|
|
86
|
+
_priceConfig.templateAddress = zeroAddress;
|
|
87
|
+
if (!creditsConfig.nftAddress || !isAddress(creditsConfig.nftAddress)) {
|
|
88
|
+
if (creditsConfig.durationSecs > 0n) {
|
|
89
|
+
_creditsConfig.nftAddress = nft1155ExpirableCreditsV2Address;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
_creditsConfig.nftAddress = nft1155CreditsAddress;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (includeFees) {
|
|
96
|
+
const fees = await this.includeFeesInPaymentsDistribution(_priceConfig, _creditsConfig);
|
|
97
|
+
_priceConfig.amounts = fees[0];
|
|
98
|
+
_priceConfig.receivers = fees[1];
|
|
99
|
+
}
|
|
100
|
+
if (organizationCryptoFee && organizationCryptoWallet) {
|
|
101
|
+
_priceConfig.amounts.push(organizationCryptoFee);
|
|
102
|
+
_priceConfig.receivers.push(organizationCryptoWallet);
|
|
103
|
+
}
|
|
104
|
+
return { priceConfig: _priceConfig, creditsConfig: _creditsConfig };
|
|
105
|
+
}
|
|
106
|
+
async hashPlanId(_priceConfig, _creditsConfig, owner, addFees = true, nonce = 0n, organizationCryptoFee, organizationCryptoWallet) {
|
|
107
|
+
const _config = await this.planConfigPreFilter(_priceConfig, _creditsConfig, addFees, organizationCryptoFee, organizationCryptoWallet);
|
|
108
|
+
return await this.contract.read.hashPlanId([
|
|
109
|
+
_config.priceConfig,
|
|
110
|
+
_config.creditsConfig,
|
|
111
|
+
owner,
|
|
112
|
+
nonce,
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @notice Checks if Nevermined fees are included in the payment distribution
|
|
117
|
+
* @param _planId The ID of the plan to check
|
|
118
|
+
* @return bool True if Nevermined fees are properly included
|
|
119
|
+
*/
|
|
120
|
+
async areNeverminedFeesIncluded(priceConfig) {
|
|
121
|
+
return await this.contract.read.areNeverminedFeesIncluded([
|
|
122
|
+
priceConfig.amounts,
|
|
123
|
+
priceConfig.receivers,
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* @notice Getting a payment distribution, it includes the Nevermined fees if not already included
|
|
128
|
+
* This method subsctracts the fees from the original amounts and adds a new entry for the fee recipient
|
|
129
|
+
* @param priceConfig The price configuration of the plan
|
|
130
|
+
* @param creditsConfig The credits configuration of the plan
|
|
131
|
+
* @return amounts Updated array of payment amounts including fees
|
|
132
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
133
|
+
*/
|
|
134
|
+
async includeFeesInPaymentsDistribution(priceConfig, creditsConfig) {
|
|
135
|
+
const result = await this.contract.read.includeFeesInPaymentsDistribution([
|
|
136
|
+
priceConfig,
|
|
137
|
+
creditsConfig,
|
|
138
|
+
]);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @notice Adds Nevermined fees to the payment distribution if not already included
|
|
143
|
+
* @param priceConfig The price configuration of the plan
|
|
144
|
+
* @param creditsConfig The credits configuration of the plan
|
|
145
|
+
* @return amounts Updated array of payment amounts including fees
|
|
146
|
+
* @return receivers Updated array of payment receivers including fee recipient
|
|
147
|
+
*/
|
|
148
|
+
async addFeesToPaymentsDistribution(priceConfig, creditsConfig) {
|
|
149
|
+
const result = await this.contract.read.addFeesToPaymentsDistribution([
|
|
150
|
+
priceConfig,
|
|
151
|
+
creditsConfig,
|
|
152
|
+
]);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 interface MulticallEntry {
|
|
6
|
+
contractName?: string;
|
|
7
|
+
contractAddress: Address;
|
|
8
|
+
abi: Abi;
|
|
9
|
+
functionName: string;
|
|
10
|
+
args: any[];
|
|
11
|
+
}
|
|
12
|
+
export interface SimulateMulticallEntry {
|
|
13
|
+
functionName: string;
|
|
14
|
+
value?: bigint;
|
|
15
|
+
abi: Abi;
|
|
16
|
+
args: any[];
|
|
17
|
+
to: Address;
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class ContractBase extends Instantiable {
|
|
20
|
+
readonly contractName: string;
|
|
21
|
+
contract: any;
|
|
22
|
+
address: Address;
|
|
23
|
+
constructor(contractName: string, address: Address);
|
|
24
|
+
protected init(config: InstantiableConfig, contractConfig: {
|
|
25
|
+
address: `0x${string}`;
|
|
26
|
+
abi: Abi;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
call<T>(functionName: string, args: any[], from?: string): Promise<T>;
|
|
29
|
+
getTransactionReceipt(txHash: UserOperationReceipt | TransactionReceipt): Promise<TransactionReceipt>;
|
|
30
|
+
getTransactionLogs(txReceipt: TransactionReceipt | UserOperationReceipt, eventName?: string): any[];
|
|
31
|
+
multicall(calls: MulticallEntry[], from: Account | SmartAccount, params?: TxParameters): Promise<TransactionReceipt>;
|
|
32
|
+
simulateMulticall(calls: SimulateMulticallEntry[], from: Account | SmartAccount, params?: TxParameters): Promise<boolean>;
|
|
33
|
+
simulate(functionName: string, from: Account | SmartAccount, args: any[], params?: TxParameters): Promise<boolean>;
|
|
34
|
+
send(functionName: string, from: Account | SmartAccount, args: any[], params?: TxParameters): Promise<TransactionReceipt | UserOperationReceipt>;
|
|
35
|
+
private internalMulticallSmartAccount;
|
|
36
|
+
private internalSendSmartAccount;
|
|
37
|
+
private internalSimulateSmartAccount;
|
|
38
|
+
private localAccountSimulate;
|
|
39
|
+
private localAccountSend;
|
|
40
|
+
private localAccountMulticall;
|
|
41
|
+
private localAccountSimulateMulticall;
|
|
42
|
+
private internalSimulateMulticallSmartAccount;
|
|
43
|
+
private getZeroDevRPC;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ContractBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractBase.d.ts","sourceRoot":"","sources":["../../src/contracts/ContractBase.ts"],"names":[],"mappings":"AAKA,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;AAKxD,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,GAAG,CAAA;IACR,YAAY,EAAE,MAAM,CAAA;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