@cheqd/sdk 2.0.2-develop.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test.yml +2 -2
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/build/index.d.ts +7 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +19 -7
- package/build/index.js.map +1 -1
- package/build/modules/_.d.ts +7 -11
- package/build/modules/_.d.ts.map +1 -1
- package/build/modules/_.js +15 -17
- package/build/modules/_.js.map +1 -1
- package/build/modules/did.d.ts +39 -15
- package/build/modules/did.d.ts.map +1 -1
- package/build/modules/did.js +187 -54
- package/build/modules/did.js.map +1 -1
- package/build/modules/resource.d.ts +23 -7
- package/build/modules/resource.d.ts.map +1 -1
- package/build/modules/resource.js +61 -18
- package/build/modules/resource.js.map +1 -1
- package/build/querier.d.ts +11 -0
- package/build/querier.d.ts.map +1 -0
- package/build/querier.js +31 -0
- package/build/querier.js.map +1 -0
- package/build/signer.d.ts +3 -5
- package/build/signer.d.ts.map +1 -1
- package/build/signer.js +13 -13
- package/build/signer.js.map +1 -1
- package/build/types.d.ts +12 -0
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/utils.js +13 -15
- package/build/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +22 -10
- package/src/modules/_.ts +13 -21
- package/src/modules/did.ts +207 -51
- package/src/modules/resource.ts +74 -12
- package/src/querier.ts +33 -0
- package/src/signer.ts +3 -6
- package/src/types.ts +17 -1
- package/src/utils.ts +1 -1
- package/tests/index.test.ts +43 -3
- package/tests/modules/did.test.ts +483 -50
- package/tests/modules/resource.test.ts +576 -30
- package/tests/signer.test.ts +2 -2
- package/tests/testutils.test.ts +8 -2
- package/tsconfig.json +1 -1
package/tests/index.test.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { localnet, faucet } from './testutils.test'
|
|
|
4
4
|
import { AbstractCheqdSDKModule } from '../src/modules/_'
|
|
5
5
|
import { CheqdSigningStargateClient } from '../src/signer'
|
|
6
6
|
import { createDefaultCheqdRegistry } from '../src/registry'
|
|
7
|
+
import { CheqdQuerier } from '../src/querier'
|
|
8
|
+
import { setupDidExtension, DidExtension, defaultDidExtensionKey } from '../src/modules/did';
|
|
9
|
+
import { QueryExtensionSetup } from '../src/types'
|
|
10
|
+
import { setupResourceExtension, ResourceExtension, defaultResourceExtensionKey } from '../src/modules/resource';
|
|
7
11
|
|
|
8
12
|
describe(
|
|
9
13
|
'CheqdSDK', () => {
|
|
@@ -18,7 +22,8 @@ describe(
|
|
|
18
22
|
|
|
19
23
|
const sdkMethods = Object.keys(cheqdSDK.methods)
|
|
20
24
|
const testSigner = await CheqdSigningStargateClient.connectWithSigner(options.rpcUrl, options.wallet)
|
|
21
|
-
const
|
|
25
|
+
const testQuerier = await CheqdQuerier.connectWithExtension(options.rpcUrl, setupDidExtension) as CheqdQuerier & DidExtension
|
|
26
|
+
const moduleMethods = Object.keys(new DIDModule(testSigner, testQuerier).methods)
|
|
22
27
|
|
|
23
28
|
moduleMethods.forEach((method) => {
|
|
24
29
|
expect(sdkMethods).toContain(method)
|
|
@@ -34,12 +39,15 @@ describe(
|
|
|
34
39
|
methods = {
|
|
35
40
|
doSomething: this.doSomething.bind(this)
|
|
36
41
|
}
|
|
37
|
-
constructor(signer: CheqdSigningStargateClient) {
|
|
38
|
-
super(signer)
|
|
42
|
+
constructor(signer: CheqdSigningStargateClient, querier: CheqdQuerier) {
|
|
43
|
+
super(signer, querier)
|
|
39
44
|
}
|
|
40
45
|
public getRegistryTypes(): Iterable<[string, GeneratedType]> {
|
|
41
46
|
return TestModule.registryTypes
|
|
42
47
|
}
|
|
48
|
+
public getQuerierExtensionSetup(): QueryExtensionSetup<{}> {
|
|
49
|
+
return () => ({})
|
|
50
|
+
}
|
|
43
51
|
async doSomething(): Promise<string> {
|
|
44
52
|
return 'did something'
|
|
45
53
|
}
|
|
@@ -90,6 +98,38 @@ describe(
|
|
|
90
98
|
|
|
91
99
|
expect(cheqdSDK.signer.registry).toStrictEqual(cheqdRegistry)
|
|
92
100
|
})
|
|
101
|
+
|
|
102
|
+
it('should instantiate querier extension from passed modules', async () => {
|
|
103
|
+
const options = {
|
|
104
|
+
modules: [DIDModule as unknown as AbstractCheqdSDKModule],
|
|
105
|
+
rpcUrl: localnet.rpcUrl,
|
|
106
|
+
wallet: await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic)
|
|
107
|
+
} as ICheqdSDKOptions
|
|
108
|
+
const cheqdSDK = await createCheqdSDK(options)
|
|
109
|
+
|
|
110
|
+
const querier = await CheqdQuerier.connectWithExtension(options.rpcUrl, setupDidExtension) as CheqdQuerier & DidExtension
|
|
111
|
+
|
|
112
|
+
// we need to stringify the querier extension because it's a proxy object
|
|
113
|
+
// and the equality check will fail
|
|
114
|
+
expect(JSON.stringify(cheqdSDK.querier[defaultDidExtensionKey])).toStrictEqual(JSON.stringify(querier[defaultDidExtensionKey]))
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should instantiate querier extension from multiple passed modules', async () => {
|
|
118
|
+
const options = {
|
|
119
|
+
modules: [DIDModule as unknown as AbstractCheqdSDKModule, ResourceModule as unknown as AbstractCheqdSDKModule],
|
|
120
|
+
rpcUrl: localnet.rpcUrl,
|
|
121
|
+
wallet: await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic)
|
|
122
|
+
} as ICheqdSDKOptions
|
|
123
|
+
const cheqdSDK = await createCheqdSDK(options)
|
|
124
|
+
|
|
125
|
+
const didQuerier = await CheqdQuerier.connectWithExtension(options.rpcUrl, setupDidExtension) as CheqdQuerier & DidExtension
|
|
126
|
+
const resourceQuerier = await CheqdQuerier.connectWithExtension(options.rpcUrl, setupResourceExtension) as CheqdQuerier & ResourceExtension
|
|
127
|
+
|
|
128
|
+
// we need to stringify the querier extension because it's a proxy object
|
|
129
|
+
// and the equality check will fail
|
|
130
|
+
expect(JSON.stringify(cheqdSDK.querier[defaultDidExtensionKey])).toStrictEqual(JSON.stringify(didQuerier[defaultDidExtensionKey]))
|
|
131
|
+
expect(JSON.stringify(cheqdSDK.querier[defaultResourceExtensionKey])).toStrictEqual(JSON.stringify(resourceQuerier[defaultResourceExtensionKey]))
|
|
132
|
+
})
|
|
93
133
|
})
|
|
94
134
|
}
|
|
95
135
|
)
|