@nevermined-io/core-kit 0.0.15 → 0.0.17-rc0
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 +0 -1
- package/dist/Instantiable.abstract.js +1 -2
- package/dist/artifacts/generated.d.ts +20 -21
- package/dist/artifacts/generated.js +10 -10
- package/dist/contracts/AccessManager.d.ts +0 -1
- package/dist/contracts/AssetRegistry.d.ts +1 -2
- package/dist/contracts/AssetRegistry.js +1 -1
- package/dist/contracts/ContractBase.d.ts +0 -1
- package/dist/contracts/ContractBase.js +0 -3
- package/dist/contracts/ContractsApi.d.ts +0 -1
- package/dist/contracts/ContractsApi.js +0 -43
- package/dist/contracts/FiatPaymentTemplate.d.ts +0 -1
- package/dist/contracts/FiatSettlementCondition.d.ts +0 -1
- package/dist/contracts/FixedPaymentTemplate.d.ts +0 -1
- package/dist/contracts/FixedPaymentTemplate.js +6 -3
- package/dist/contracts/NFT1155Base.d.ts +0 -1
- package/dist/contracts/NFT1155Credits.d.ts +0 -1
- package/dist/contracts/NFT1155ExpirableCredits.d.ts +0 -1
- package/dist/contracts/NVMConfig.d.ts +0 -1
- package/dist/contracts/ProtocolStandardFees.d.ts +1 -2
- package/dist/contracts/Roles.d.ts +0 -1
- package/dist/contracts/index.d.ts +0 -1
- package/dist/errors/NeverminedErrors.d.ts +0 -1
- package/dist/errors/index.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +7 -7
- package/dist/models/AgentAccessToken.d.ts +0 -1
- package/dist/models/AgentAccessToken.js +0 -22
- package/dist/models/Logger.d.ts +0 -1
- package/dist/models/NeverminedOptions.d.ts +0 -1
- package/dist/models/NeverminedOptions.js +6 -26
- package/dist/models/NvmApiKey.d.ts +0 -1
- package/dist/models/NvmApiKey.js +6 -36
- package/dist/models/Transactions.d.ts +0 -1
- package/dist/models/index.d.ts +0 -1
- package/dist/nevermined/DID.d.ts +0 -1
- package/dist/nevermined/DID.js +0 -4
- package/dist/nevermined/Nevermined.d.ts +0 -1
- package/dist/nevermined/Nevermined.js +0 -21
- package/dist/nevermined/api/PaymentsApi.d.ts +1 -2
- package/dist/nevermined/api/PaymentsApi.js +5 -1
- package/dist/nevermined/api/ServicesApi.d.ts +0 -1
- package/dist/nevermined/api/ServicesApi.js +0 -12
- package/dist/nevermined/api/UtilsApi.d.ts +0 -1
- package/dist/nevermined/api/UtilsApi.js +0 -12
- package/dist/nevermined/index.d.ts +0 -1
- package/dist/nevermined/utils/AgentUtils.d.ts +1 -2
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts +0 -1
- package/dist/nevermined/utils/JwtUtils.d.ts +1 -2
- package/dist/nevermined/utils/JwtUtils.js +1 -5
- package/dist/nevermined/utils/SignatureUtils.d.ts +1 -2
- package/dist/nevermined/utils/WebServiceConnector.d.ts +0 -1
- package/dist/nevermined/utils/WebServiceConnector.js +0 -2
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts +0 -1
- package/dist/nevermined/utils/index.d.ts +0 -1
- package/dist/services/Api.d.ts +0 -1
- package/dist/services/MetadataService.d.ts +1 -2
- package/dist/services/MetadataService.js +1 -1
- package/dist/services/Profiles.d.ts +1 -2
- package/dist/services/index.d.ts +0 -1
- package/dist/utils/ConversionTypeHelpers.d.ts +0 -1
- package/dist/utils/Network.d.ts +0 -1
- package/dist/utils/helpers.d.ts +1 -2
- package/dist/utils/index.d.ts +0 -1
- package/dist/vendor/commons/index.d.ts +4 -0
- package/dist/vendor/commons/index.js +4 -0
- package/dist/vendor/commons/lib/constants/AssetConstants.d.ts +3 -0
- package/dist/vendor/commons/lib/constants/AssetConstants.js +3 -0
- package/dist/vendor/commons/lib/constants/index.d.ts +2 -0
- package/dist/vendor/commons/lib/constants/index.js +1 -0
- package/dist/vendor/commons/lib/ddo/DDO.d.ts +39 -0
- package/dist/vendor/commons/lib/ddo/DDO.js +95 -0
- package/dist/vendor/commons/lib/ddo/index.d.ts +1 -0
- package/dist/vendor/commons/lib/ddo/index.js +1 -0
- package/dist/vendor/commons/lib/types/ContractsTypes.d.ts +98 -0
- package/dist/vendor/commons/lib/types/ContractsTypes.js +36 -0
- package/dist/vendor/commons/lib/types/DDOTypes.d.ts +113 -0
- package/dist/vendor/commons/lib/types/DDOTypes.js +14 -0
- package/dist/vendor/commons/lib/types/GeneralTypes.d.ts +19 -0
- package/dist/vendor/commons/lib/types/GeneralTypes.js +1 -0
- package/dist/vendor/commons/lib/types/MetadataTypes.d.ts +120 -0
- package/dist/vendor/commons/lib/types/MetadataTypes.js +57 -0
- package/dist/vendor/commons/lib/types/TranscoderTypes.d.ts +27 -0
- package/dist/vendor/commons/lib/types/TranscoderTypes.js +30 -0
- package/dist/vendor/commons/lib/types/index.d.ts +6 -0
- package/dist/vendor/commons/lib/types/index.js +6 -0
- package/dist/vendor/commons/lib/types/types.d.ts +202 -0
- package/dist/vendor/commons/lib/types/types.js +140 -0
- package/package.json +36 -1
- package/dist/Instantiable.abstract.d.ts.map +0 -1
- package/dist/artifacts/generated.d.ts.map +0 -1
- package/dist/contracts/AccessManager.d.ts.map +0 -1
- package/dist/contracts/AssetRegistry.d.ts.map +0 -1
- package/dist/contracts/ContractBase.d.ts.map +0 -1
- package/dist/contracts/ContractsApi.d.ts.map +0 -1
- package/dist/contracts/FiatPaymentTemplate.d.ts.map +0 -1
- package/dist/contracts/FiatSettlementCondition.d.ts.map +0 -1
- package/dist/contracts/FixedPaymentTemplate.d.ts.map +0 -1
- package/dist/contracts/NFT1155Base.d.ts.map +0 -1
- package/dist/contracts/NFT1155Credits.d.ts.map +0 -1
- package/dist/contracts/NFT1155ExpirableCredits.d.ts.map +0 -1
- package/dist/contracts/NVMConfig.d.ts.map +0 -1
- package/dist/contracts/ProtocolStandardFees.d.ts.map +0 -1
- package/dist/contracts/Roles.d.ts.map +0 -1
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/errors/NeverminedErrors.d.ts.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/models/AgentAccessToken.d.ts.map +0 -1
- package/dist/models/Logger.d.ts.map +0 -1
- package/dist/models/NeverminedOptions.d.ts.map +0 -1
- package/dist/models/NvmApiKey.d.ts.map +0 -1
- package/dist/models/Transactions.d.ts.map +0 -1
- package/dist/models/index.d.ts.map +0 -1
- package/dist/nevermined/DID.d.ts.map +0 -1
- package/dist/nevermined/Nevermined.d.ts.map +0 -1
- package/dist/nevermined/api/PaymentsApi.d.ts.map +0 -1
- package/dist/nevermined/api/ServicesApi.d.ts.map +0 -1
- package/dist/nevermined/api/UtilsApi.d.ts.map +0 -1
- package/dist/nevermined/index.d.ts.map +0 -1
- package/dist/nevermined/utils/AgentUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/BlockchainViemUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/JwtUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/SignatureUtils.d.ts.map +0 -1
- package/dist/nevermined/utils/WebServiceConnector.d.ts.map +0 -1
- package/dist/nevermined/utils/ZeroDevPolicies.d.ts.map +0 -1
- package/dist/nevermined/utils/index.d.ts.map +0 -1
- package/dist/services/Api.d.ts.map +0 -1
- package/dist/services/MetadataService.d.ts.map +0 -1
- package/dist/services/Profiles.d.ts.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/utils/ConversionTypeHelpers.d.ts.map +0 -1
- package/dist/utils/Network.d.ts.map +0 -1
- package/dist/utils/helpers.d.ts.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
|
@@ -45,27 +45,6 @@ export class Nevermined extends Instantiable {
|
|
|
45
45
|
}
|
|
46
46
|
return instance;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* ContractsApi instance.
|
|
50
|
-
*/
|
|
51
|
-
contracts;
|
|
52
|
-
/**
|
|
53
|
-
* SearchApi API
|
|
54
|
-
*/
|
|
55
|
-
services;
|
|
56
|
-
/**
|
|
57
|
-
* Utils submodule
|
|
58
|
-
*/
|
|
59
|
-
utils;
|
|
60
|
-
payments;
|
|
61
|
-
/**
|
|
62
|
-
* Web3 Clients
|
|
63
|
-
*/
|
|
64
|
-
// public web3: Web3Clients
|
|
65
|
-
/**
|
|
66
|
-
* If contracts are initialized
|
|
67
|
-
*/
|
|
68
|
-
contractsInitialized;
|
|
69
48
|
constructor() {
|
|
70
49
|
super();
|
|
71
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, Address } from 'viem';
|
|
2
2
|
import { Instantiable, InstantiableConfig } from '../../Instantiable.abstract.js';
|
|
3
3
|
import { SmartAccount } from 'viem/account-abstraction';
|
|
4
|
-
import {
|
|
4
|
+
import { OrderResult, Plan } from "../../vendor/commons";
|
|
5
5
|
export declare class PaymentsApi extends Instantiable {
|
|
6
6
|
/**
|
|
7
7
|
* Creates a new PaymentsApi
|
|
@@ -19,4 +19,3 @@ export declare class PaymentsApi extends Instantiable {
|
|
|
19
19
|
orderFiatPayment(planId: bigint, planReceiver: Address, from: Account | SmartAccount): Promise<OrderResult>;
|
|
20
20
|
orderCryptoPayment(planId: bigint, plan: Plan, from: Account | SmartAccount): Promise<OrderResult>;
|
|
21
21
|
}
|
|
22
|
-
//# sourceMappingURL=PaymentsApi.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isAddress, parseAbi, zeroAddress } from 'viem';
|
|
2
2
|
import { Instantiable } from '../../Instantiable.abstract.js';
|
|
3
|
-
import {
|
|
3
|
+
import { PlanTransactionPaymentType } from "../../vendor/commons";
|
|
4
4
|
import { NotEnoughBalance } from '../../errors/NeverminedErrors.js';
|
|
5
5
|
const TOKEN_BALANCE_ABI = parseAbi(['function balanceOf(address) view returns (uint256)']);
|
|
6
6
|
const GET_FEE_RATES_ABI = parseAbi([
|
|
@@ -101,6 +101,10 @@ export class PaymentsApi extends Instantiable {
|
|
|
101
101
|
else {
|
|
102
102
|
txHash = await this.nevermined.contracts.fixedPaymentTemplate.createAgreement(planId, from);
|
|
103
103
|
}
|
|
104
|
+
if (!txHash) {
|
|
105
|
+
this.logger.error('Error in PaymentsApi order method: txHash not defined');
|
|
106
|
+
throw new Error('txHash not defined');
|
|
107
|
+
}
|
|
104
108
|
const txReceipt = await this.nevermined.contracts.assetRegistry.getTransactionReceipt(txHash);
|
|
105
109
|
return {
|
|
106
110
|
txHash: txReceipt.transactionHash,
|
|
@@ -6,18 +6,6 @@ import { Profiles } from '../../services/Profiles.js';
|
|
|
6
6
|
* Utils internal submodule of Nevermined.
|
|
7
7
|
*/
|
|
8
8
|
export class ServicesApi extends Instantiable {
|
|
9
|
-
/**
|
|
10
|
-
* Nevermined Node Service
|
|
11
|
-
*/
|
|
12
|
-
api;
|
|
13
|
-
/**
|
|
14
|
-
* Marketplace instance.
|
|
15
|
-
*/
|
|
16
|
-
metadata;
|
|
17
|
-
/**
|
|
18
|
-
* Profiles instance
|
|
19
|
-
*/
|
|
20
|
-
profiles;
|
|
21
9
|
/**
|
|
22
10
|
* Creates a new ServicesApi
|
|
23
11
|
* @param config - Configuration of the Nevermined instance
|
|
@@ -6,18 +6,6 @@ import { WebServiceConnector } from '../utils/WebServiceConnector.js';
|
|
|
6
6
|
* Nevermined Utils API
|
|
7
7
|
*/
|
|
8
8
|
export class UtilsApi extends Instantiable {
|
|
9
|
-
/**
|
|
10
|
-
* Fetch utils.
|
|
11
|
-
*/
|
|
12
|
-
fetch;
|
|
13
|
-
/**
|
|
14
|
-
* Jwt utils.
|
|
15
|
-
*/
|
|
16
|
-
jwt;
|
|
17
|
-
/**
|
|
18
|
-
* Signature utils.
|
|
19
|
-
*/
|
|
20
|
-
signature;
|
|
21
9
|
/**
|
|
22
10
|
* Creates a new AssetsApi
|
|
23
11
|
* @param config - Configuration of the Nevermined instance
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiEndpoint } from "../../vendor/commons";
|
|
2
2
|
export declare function isEndpointRequestedIncluded(requestEndpoint: string, requestedHTTPVerb: string, agentEndpoints: ApiEndpoint[], agentOpenEndpoints?: string[]): {
|
|
3
3
|
matches: boolean;
|
|
4
4
|
urlMatching?: URL;
|
|
5
5
|
verbMatching?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function areUrlsEqualIgnoringQuery(url1: URL, url2: URL): boolean;
|
|
8
|
-
//# sourceMappingURL=AgentUtils.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Eip712Data } from "../../vendor/commons";
|
|
2
2
|
import { type JWSHeaderParameters, SignJWT } from 'jose';
|
|
3
3
|
import { type Account } from 'viem';
|
|
4
4
|
import { SmartAccount } from 'viem/account-abstraction';
|
|
@@ -24,4 +24,3 @@ export declare class JwtUtils extends Instantiable {
|
|
|
24
24
|
static createCompressedJwt(token: string): string;
|
|
25
25
|
static decompressJwt(compressedJwt: string): string;
|
|
26
26
|
}
|
|
27
|
-
//# sourceMappingURL=JwtUtils.d.ts.map
|
|
@@ -6,7 +6,6 @@ import { urlSafeBase64Decode, urlSafeBase64Encode } from '../../utils/helpers.js
|
|
|
6
6
|
import { getChecksumAddress } from './BlockchainViemUtils.js';
|
|
7
7
|
import { SignatureUtils } from './SignatureUtils.js';
|
|
8
8
|
export class EthSignJWT extends SignJWT {
|
|
9
|
-
protectedHeader;
|
|
10
9
|
setProtectedHeader(protectedHeader) {
|
|
11
10
|
this.protectedHeader = protectedHeader;
|
|
12
11
|
return this;
|
|
@@ -82,10 +81,6 @@ export class EthSignJWT extends SignJWT {
|
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
export class JwtUtils extends Instantiable {
|
|
85
|
-
static CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
|
|
86
|
-
// BASE_AUD = '/api/v1/node/services'
|
|
87
|
-
tokenCache;
|
|
88
|
-
signatureUtils;
|
|
89
84
|
constructor(config) {
|
|
90
85
|
super();
|
|
91
86
|
this.setInstanceConfig(config);
|
|
@@ -159,3 +154,4 @@ export class JwtUtils extends Instantiable {
|
|
|
159
154
|
return new TextDecoder().decode(decompressed);
|
|
160
155
|
}
|
|
161
156
|
}
|
|
157
|
+
JwtUtils.CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Account, type Hash } from 'viem';
|
|
2
2
|
import { Instantiable, InstantiableConfig } from '../../Instantiable.abstract.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TypedDataDomain, TypedDataTypes } from "../../vendor/commons";
|
|
4
4
|
import { SmartAccount } from 'viem/account-abstraction';
|
|
5
5
|
export declare class SignatureUtils extends Instantiable {
|
|
6
6
|
constructor(config: InstantiableConfig);
|
|
@@ -11,4 +11,3 @@ export declare class SignatureUtils extends Instantiable {
|
|
|
11
11
|
static recoverSignerAddress(message: string, signature: string): Promise<string>;
|
|
12
12
|
static hash(seed: string): string;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=SignatureUtils.d.ts.map
|
|
@@ -16,4 +16,3 @@ export declare const getBurnNFTPolicy: () => import("@zerodev/permissions").Poli
|
|
|
16
16
|
export declare const getRegisterPolicy: () => import("@zerodev/permissions").Policy;
|
|
17
17
|
export declare const buildPolicy: (permissions: string[], contractAddress: `0x${string}`) => import("@zerodev/permissions").Policy;
|
|
18
18
|
export declare const getAllContractsPolicy: (contractAddress: `0x${string}`) => import("@zerodev/permissions").Policy;
|
|
19
|
-
//# sourceMappingURL=ZeroDevPolicies.d.ts.map
|
package/dist/services/Api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DDO, SearchQuery } from "../vendor/commons";
|
|
2
2
|
import { DID } from '../nevermined/DID.js';
|
|
3
3
|
import { Api } from './Api.js';
|
|
4
4
|
export declare const apiPath = "/api/v1/protocol/agents";
|
|
@@ -50,4 +50,3 @@ export declare class MetadataService extends Api {
|
|
|
50
50
|
retrieveDDOByUrl(metadataServiceEndpoint?: string): Promise<DDO>;
|
|
51
51
|
getServiceEndpoint(did: DID): string;
|
|
52
52
|
}
|
|
53
|
-
//# sourceMappingURL=MetadataService.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NewProfile, Profile, ReducedProfile } from "../vendor/commons";
|
|
2
2
|
import { Api } from './Api.js';
|
|
3
3
|
export declare class Profiles extends Api {
|
|
4
4
|
/**
|
|
@@ -13,4 +13,3 @@ export declare class Profiles extends Api {
|
|
|
13
13
|
findOneByAddress(address: string): Promise<ReducedProfile>;
|
|
14
14
|
disableOneByUserId(userId: string, backendAuthToken: string): Promise<Profile>;
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=Profiles.d.ts.map
|
package/dist/services/index.d.ts
CHANGED
|
@@ -5,4 +5,3 @@ export declare const didPrefixed: (input: string) => string;
|
|
|
5
5
|
export declare const noDidPrefixed: (input: string) => string;
|
|
6
6
|
export declare function didTransformer(input: string | undefined, prefixOutput: boolean): string;
|
|
7
7
|
export declare const didZeroX: (input: string) => `0x${string}`;
|
|
8
|
-
//# sourceMappingURL=ConversionTypeHelpers.d.ts.map
|
package/dist/utils/Network.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ import { type Chain } from 'viem/chains';
|
|
|
2
2
|
export declare function getNetworkName(networkId: number): Promise<string>;
|
|
3
3
|
export declare function isTestnet(networkId: number): boolean;
|
|
4
4
|
export declare function getChain(networkId: number | undefined): Chain;
|
|
5
|
-
//# sourceMappingURL=Network.d.ts.map
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchQuery } from "../vendor/commons";
|
|
2
2
|
import { URL } from 'whatwg-url';
|
|
3
3
|
interface ECIES {
|
|
4
4
|
iv: Buffer;
|
|
@@ -20,4 +20,3 @@ export declare function serializeECIES(ecies: ECIES): string;
|
|
|
20
20
|
export declare function deserializeECIES(serialized: string): ECIES;
|
|
21
21
|
export declare function decryptMessage(encryptedMessage: string, privateKey: string | any): Promise<string>;
|
|
22
22
|
export {};
|
|
23
|
-
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_ENCRYPTION_METHOD, NETWORK_FEE_DENOMINATOR } from './AssetConstants.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DIDAsset, Plan } from '../types/ContractsTypes.js';
|
|
2
|
+
import { Metadata, NvmConfig } from '../types/DDOTypes.js';
|
|
3
|
+
type Registry = DIDAsset | Plan;
|
|
4
|
+
export declare class DDO {
|
|
5
|
+
/**
|
|
6
|
+
* Serializes the DDO object.
|
|
7
|
+
* @param ddo - The {@link DDO} to be serialized.
|
|
8
|
+
* @returns DDO serialized.
|
|
9
|
+
*/
|
|
10
|
+
static serialize(ddo: DDO): string;
|
|
11
|
+
/**
|
|
12
|
+
* Deserializes the DDO object.
|
|
13
|
+
* @param ddoString - The serialized {@link DDO} to be deserialized.
|
|
14
|
+
* @returns The deserialized {@link DDO}.
|
|
15
|
+
*/
|
|
16
|
+
static deserialize(ddoString: string): DDO;
|
|
17
|
+
/**
|
|
18
|
+
* DID, decentralizes ID.
|
|
19
|
+
*/
|
|
20
|
+
id: string;
|
|
21
|
+
['@context']: string;
|
|
22
|
+
_nvm: NvmConfig;
|
|
23
|
+
created: string;
|
|
24
|
+
updated?: string;
|
|
25
|
+
metadata: Metadata;
|
|
26
|
+
registry: Registry;
|
|
27
|
+
constructor(ddo?: Partial<DDO>);
|
|
28
|
+
}
|
|
29
|
+
export declare class AgentDDO extends DDO {
|
|
30
|
+
registry: DIDAsset;
|
|
31
|
+
constructor(ddo?: Partial<AgentDDO>);
|
|
32
|
+
static getInstance(userId: string, userAddress: string, appId?: string): AgentDDO;
|
|
33
|
+
}
|
|
34
|
+
export declare class PlanDDO extends DDO {
|
|
35
|
+
registry: Plan;
|
|
36
|
+
constructor(ddo?: Partial<PlanDDO>);
|
|
37
|
+
static getInstance(userId: string, userAddress: string, appId?: string): PlanDDO;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const jsonReplacer = (_key, value) => {
|
|
2
|
+
// Modify the value or return undefined to exclude the property
|
|
3
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
4
|
+
};
|
|
5
|
+
export class DDO {
|
|
6
|
+
/**
|
|
7
|
+
* Serializes the DDO object.
|
|
8
|
+
* @param ddo - The {@link DDO} to be serialized.
|
|
9
|
+
* @returns DDO serialized.
|
|
10
|
+
*/
|
|
11
|
+
static serialize(ddo) {
|
|
12
|
+
return JSON.stringify(ddo, jsonReplacer, 2);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Deserializes the DDO object.
|
|
16
|
+
* @param ddoString - The serialized {@link DDO} to be deserialized.
|
|
17
|
+
* @returns The deserialized {@link DDO}.
|
|
18
|
+
*/
|
|
19
|
+
static deserialize(ddoString) {
|
|
20
|
+
const ddo = JSON.parse(ddoString);
|
|
21
|
+
return new DDO(ddo);
|
|
22
|
+
}
|
|
23
|
+
constructor(ddo = {}) {
|
|
24
|
+
/**
|
|
25
|
+
* DID, decentralizes ID.
|
|
26
|
+
*/
|
|
27
|
+
this.id = '';
|
|
28
|
+
// public didSeed = ''
|
|
29
|
+
this['@context'] = 'https://w3id.org/did/v1';
|
|
30
|
+
this._nvm = { userId: '', userAddress: '', appId: '', versions: [] };
|
|
31
|
+
this.created = new Date().toISOString().replace(/\.[0-9]{3}/, '');
|
|
32
|
+
this.metadata = {
|
|
33
|
+
serviceEndpoint: '',
|
|
34
|
+
main: {
|
|
35
|
+
name: '',
|
|
36
|
+
description: '',
|
|
37
|
+
dateCreated: '',
|
|
38
|
+
datePublished: '',
|
|
39
|
+
license: '',
|
|
40
|
+
tags: [],
|
|
41
|
+
},
|
|
42
|
+
curation: {
|
|
43
|
+
numVotes: 0,
|
|
44
|
+
rating: 0,
|
|
45
|
+
schema: '',
|
|
46
|
+
isListed: true,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
Object.assign(this, ddo, {
|
|
50
|
+
created: (ddo && ddo.created) || new Date().toISOString().replace(/\.[0-9]{3}/, ''),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class AgentDDO extends DDO {
|
|
55
|
+
constructor(ddo = {}) {
|
|
56
|
+
super(ddo);
|
|
57
|
+
this.registry = {
|
|
58
|
+
owner: '0x',
|
|
59
|
+
creator: '0x',
|
|
60
|
+
url: '',
|
|
61
|
+
lastUpdated: 0n,
|
|
62
|
+
plans: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
static getInstance(userId, userAddress, appId) {
|
|
66
|
+
return new AgentDDO({
|
|
67
|
+
id: '',
|
|
68
|
+
_nvm: { userId, userAddress, appId: appId || '', versions: [] },
|
|
69
|
+
registry: { owner: '0x', creator: '0x', url: '', lastUpdated: 0n, plans: [] },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class PlanDDO extends DDO {
|
|
74
|
+
constructor(ddo = {}) {
|
|
75
|
+
super(ddo);
|
|
76
|
+
this.registry = {
|
|
77
|
+
owner: '0x',
|
|
78
|
+
price: {},
|
|
79
|
+
credits: {},
|
|
80
|
+
lastUpdated: 0n,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static getInstance(userId, userAddress, appId) {
|
|
84
|
+
return new PlanDDO({
|
|
85
|
+
id: '',
|
|
86
|
+
_nvm: { userId, userAddress, appId: appId || '', versions: [] },
|
|
87
|
+
registry: {
|
|
88
|
+
owner: '0x',
|
|
89
|
+
price: {},
|
|
90
|
+
credits: {},
|
|
91
|
+
lastUpdated: 0n,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DDO.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DDO.js';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
export declare enum PriceType {
|
|
3
|
+
FIXED_PRICE = 0,
|
|
4
|
+
FIXED_FIAT_PRICE = 1,
|
|
5
|
+
SMART_CONTRACT_PRICE = 2
|
|
6
|
+
}
|
|
7
|
+
export declare enum CreditsType {
|
|
8
|
+
EXPIRABLE = 0,
|
|
9
|
+
FIXED = 1,
|
|
10
|
+
DYNAMIC = 2
|
|
11
|
+
}
|
|
12
|
+
export declare enum RedemptionType {
|
|
13
|
+
ONLY_GLOBAL_ROLE = 0,
|
|
14
|
+
ONLY_OWNER = 1,
|
|
15
|
+
ONLY_PLAN_ROLE = 2
|
|
16
|
+
}
|
|
17
|
+
export interface DIDAsset {
|
|
18
|
+
owner: Address;
|
|
19
|
+
creator: Address;
|
|
20
|
+
url: string;
|
|
21
|
+
lastUpdated: bigint;
|
|
22
|
+
plans: bigint[];
|
|
23
|
+
}
|
|
24
|
+
export interface PriceConfig {
|
|
25
|
+
/**
|
|
26
|
+
* The type or configuration of the price
|
|
27
|
+
* @notice 0 - fixed price. 1 - fixed fiat price. 2 - smart contract price
|
|
28
|
+
*/
|
|
29
|
+
priceType: PriceType;
|
|
30
|
+
/**
|
|
31
|
+
* The address of the token (ERC20 or Native if zero address) for paying the plan
|
|
32
|
+
* @notice only if priceType == FIXED_PRICE or SMART_CONTRACT_PRICE
|
|
33
|
+
*/
|
|
34
|
+
tokenAddress?: Address;
|
|
35
|
+
/**
|
|
36
|
+
* The amounts to be paid for the plan
|
|
37
|
+
* @notice only if priceType == FIXED_PRICE or FIXED_FIAT_PRICE
|
|
38
|
+
*/
|
|
39
|
+
amounts: bigint[];
|
|
40
|
+
/**
|
|
41
|
+
* The receivers of the payments of the plan
|
|
42
|
+
* @notice only if priceType == FIXED_PRICE
|
|
43
|
+
*/
|
|
44
|
+
receivers: string[];
|
|
45
|
+
/**
|
|
46
|
+
* The address of the smart contract that calculates the price
|
|
47
|
+
* @notice only if priceType == SMART_CONTRACT_PRICE
|
|
48
|
+
*/
|
|
49
|
+
contractAddress?: Address;
|
|
50
|
+
/**
|
|
51
|
+
* The address of the fee controller contract, if any
|
|
52
|
+
* @notice if not given, the fee controller is the default one
|
|
53
|
+
*/
|
|
54
|
+
feeController?: Address;
|
|
55
|
+
}
|
|
56
|
+
export interface CreditsConfig {
|
|
57
|
+
/**
|
|
58
|
+
* The type of configuration of the credits type
|
|
59
|
+
*/
|
|
60
|
+
creditsType: CreditsType;
|
|
61
|
+
/**
|
|
62
|
+
* How the credits can be redeemed
|
|
63
|
+
*/
|
|
64
|
+
redemptionType: RedemptionType;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the credits burn proof signed by the user is required
|
|
67
|
+
*/
|
|
68
|
+
proofRequired: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The duration of the credits in seconds
|
|
71
|
+
* @notice only if creditsType == EXPIRABLE
|
|
72
|
+
*/
|
|
73
|
+
durationSecs: bigint;
|
|
74
|
+
/**
|
|
75
|
+
* The amount of credits that are granted when purchasing the plan
|
|
76
|
+
*/
|
|
77
|
+
amount: bigint;
|
|
78
|
+
/**
|
|
79
|
+
* The minimum number of credits redeemed when using the plan
|
|
80
|
+
* @notice only if creditsType == FIXED or DYNAMIC
|
|
81
|
+
*/
|
|
82
|
+
minAmount: bigint;
|
|
83
|
+
/**
|
|
84
|
+
* The maximum number of credits redeemed when using the plan
|
|
85
|
+
* @notice only if creditsType == DYNAMIC
|
|
86
|
+
*/
|
|
87
|
+
maxAmount: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* The address of the NFT contract that represents the plan's credits
|
|
90
|
+
*/
|
|
91
|
+
nftAddress?: Address;
|
|
92
|
+
}
|
|
93
|
+
export declare class Plan {
|
|
94
|
+
owner: Address;
|
|
95
|
+
price: PriceConfig;
|
|
96
|
+
credits: CreditsConfig;
|
|
97
|
+
lastUpdated: bigint;
|
|
98
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// Different types of prices that can be configured for a plan
|
|
2
|
+
/// @notice 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE
|
|
3
|
+
/// If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token
|
|
4
|
+
/// If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)
|
|
5
|
+
/// If SMART_CONTRACT_PRICE it means the plan can be paid in crypto and the amount to be paid is calculated by a smart contract
|
|
6
|
+
export var PriceType;
|
|
7
|
+
(function (PriceType) {
|
|
8
|
+
PriceType[PriceType["FIXED_PRICE"] = 0] = "FIXED_PRICE";
|
|
9
|
+
PriceType[PriceType["FIXED_FIAT_PRICE"] = 1] = "FIXED_FIAT_PRICE";
|
|
10
|
+
PriceType[PriceType["SMART_CONTRACT_PRICE"] = 2] = "SMART_CONTRACT_PRICE";
|
|
11
|
+
})(PriceType || (PriceType = {}));
|
|
12
|
+
/// Different types of credits that can be obtained when purchasing a plan
|
|
13
|
+
/// @notice 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC
|
|
14
|
+
/// If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)
|
|
15
|
+
/// If FIXED it means the credits can be used for a fixed amount of times
|
|
16
|
+
/// If DYNAMIC it means the credits can be used but the redemption amount is dynamic
|
|
17
|
+
export var CreditsType;
|
|
18
|
+
(function (CreditsType) {
|
|
19
|
+
CreditsType[CreditsType["EXPIRABLE"] = 0] = "EXPIRABLE";
|
|
20
|
+
CreditsType[CreditsType["FIXED"] = 1] = "FIXED";
|
|
21
|
+
CreditsType[CreditsType["DYNAMIC"] = 2] = "DYNAMIC";
|
|
22
|
+
})(CreditsType || (CreditsType = {}));
|
|
23
|
+
/// Different types of redemptions criterias that can be used when redeeming credits
|
|
24
|
+
/// @notice 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER
|
|
25
|
+
/// If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`
|
|
26
|
+
/// If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan
|
|
27
|
+
/// If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan
|
|
28
|
+
export var RedemptionType;
|
|
29
|
+
(function (RedemptionType) {
|
|
30
|
+
RedemptionType[RedemptionType["ONLY_GLOBAL_ROLE"] = 0] = "ONLY_GLOBAL_ROLE";
|
|
31
|
+
RedemptionType[RedemptionType["ONLY_OWNER"] = 1] = "ONLY_OWNER";
|
|
32
|
+
RedemptionType[RedemptionType["ONLY_PLAN_ROLE"] = 2] = "ONLY_PLAN_ROLE";
|
|
33
|
+
})(RedemptionType || (RedemptionType = {}));
|
|
34
|
+
/// Definition of a plan
|
|
35
|
+
export class Plan {
|
|
36
|
+
}
|