@cheqd/sdk 1.2.0 → 1.2.3
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/CHANGELOG.md +21 -0
- package/build/index.d.ts +33 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +76 -0
- package/build/index.js.map +1 -0
- package/build/modules/_.d.ts +24 -0
- package/build/modules/_.d.ts.map +1 -0
- package/build/modules/_.js +47 -0
- package/build/modules/_.js.map +1 -0
- package/build/modules/did.d.ts +43 -0
- package/build/modules/did.d.ts.map +1 -0
- package/build/modules/did.js +89 -0
- package/build/modules/did.js.map +1 -0
- package/build/modules/resources.d.ts +10 -0
- package/build/modules/resources.d.ts.map +1 -0
- package/build/modules/resources.js +15 -0
- package/build/modules/resources.js.map +1 -0
- package/build/registry.d.ts +4 -0
- package/build/registry.d.ts.map +1 -0
- package/build/registry.js +13 -0
- package/build/registry.js.map +1 -0
- package/build/signer.d.ts +37 -0
- package/build/signer.d.ts.map +1 -0
- package/build/signer.js +182 -0
- package/build/signer.js.map +1 -0
- package/build/types.d.ts +54 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +19 -0
- package/build/types.js.map +1 -0
- package/build/utils.d.ts +13 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +42 -0
- package/build/utils.js.map +1 -0
- package/package.json +5 -2
- package/src/signer.ts +3 -1
- package/tests/modules/did.test.ts +0 -1
- package/tsconfig.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.2.3](https://github.com/cheqd/sdk/compare/1.2.2...1.2.3) (2022-08-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **build:** Fixed build type declarations standalones ([ffadfe5](https://github.com/cheqd/sdk/commit/ffadfe553be49a11d2bb347341b90964c75adb23))
|
|
9
|
+
|
|
10
|
+
## [1.2.2](https://github.com/cheqd/sdk/compare/1.2.1...1.2.2) (2022-08-04)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **build:** Added deep level support of iterables ([1aeaea3](https://github.com/cheqd/sdk/commit/1aeaea3ed8062f1d1853930bd792b1c988e616d5))
|
|
16
|
+
|
|
17
|
+
## [1.2.1](https://github.com/cheqd/sdk/compare/1.2.0...1.2.1) (2022-08-04)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **types:** Fixed type mismatch on compilation ([c0cfbd5](https://github.com/cheqd/sdk/commit/c0cfbd500ccd8cfb0d56ccf431fbd41886a5a3a6))
|
|
23
|
+
|
|
3
24
|
## [1.2.0](https://github.com/cheqd/sdk/compare/1.1.0...1.2.0) (2022-08-03)
|
|
4
25
|
|
|
5
26
|
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
2
|
+
import { DIDModule, MinimalImportableDIDModule } from './modules/did';
|
|
3
|
+
import { MinimalImportableResourcesModule, ResourcesModule } from './modules/resources';
|
|
4
|
+
import { AbstractCheqdSDKModule } from './modules/_';
|
|
5
|
+
import { CheqdSigningStargateClient } from './signer';
|
|
6
|
+
import { CheqdNetwork, IModuleMethodMap } from './types';
|
|
7
|
+
import { createSignInputsFromImportableEd25519Key } from './utils';
|
|
8
|
+
export interface ICheqdSDKOptions {
|
|
9
|
+
modules: AbstractCheqdSDKModule[];
|
|
10
|
+
authorizedMethods?: string[];
|
|
11
|
+
network?: CheqdNetwork;
|
|
12
|
+
rpcUrl: string;
|
|
13
|
+
readonly wallet: OfflineSigner;
|
|
14
|
+
}
|
|
15
|
+
export declare type DefaultCheqdSDKModules = MinimalImportableDIDModule & MinimalImportableResourcesModule;
|
|
16
|
+
export interface CheqdSDK extends DefaultCheqdSDKModules {
|
|
17
|
+
}
|
|
18
|
+
export declare class CheqdSDK {
|
|
19
|
+
methods: IModuleMethodMap;
|
|
20
|
+
signer: CheqdSigningStargateClient;
|
|
21
|
+
options: ICheqdSDKOptions;
|
|
22
|
+
private protectedMethods;
|
|
23
|
+
constructor(options: ICheqdSDKOptions);
|
|
24
|
+
execute<P = any, R = any>(method: string, ...params: P[]): Promise<R>;
|
|
25
|
+
private loadModules;
|
|
26
|
+
private loadRegistry;
|
|
27
|
+
build(): Promise<CheqdSDK>;
|
|
28
|
+
}
|
|
29
|
+
export declare function filterUnauthorizedMethods(methods: IModuleMethodMap, authorizedMethods: string[], protectedMethods: string[]): IModuleMethodMap;
|
|
30
|
+
export declare function createCheqdSDK(options: ICheqdSDKOptions): Promise<CheqdSDK>;
|
|
31
|
+
export { DIDModule, ResourcesModule };
|
|
32
|
+
export { createSignInputsFromImportableEd25519Key };
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAY,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,EAAE,gCAAgC,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACvF,OAAO,EAAE,sBAAsB,EAAmF,MAAM,aAAa,CAAA;AAErI,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,YAAY,EAAY,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,EAAE,wCAAwC,EAAE,MAAM,SAAS,CAAA;AAElE,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,sBAAsB,EAAE,CAAA;IACjC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAC9B;AAED,oBAAY,sBAAsB,GAAG,0BAA0B,GAAG,gCAAgC,CAAA;AAElG,MAAM,WAAW,QAAS,SAAQ,sBAAsB;CAAI;AAE5D,qBAAa,QAAQ;IACpB,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,EAAE,0BAA0B,CAAA;IAClC,OAAO,EAAE,gBAAgB,CAAA;IACzB,OAAO,CAAC,gBAAgB,CAAoE;gBAEhF,OAAO,EAAE,gBAAgB;IAe/B,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAO3E,OAAO,CAAC,WAAW;IAgBhB,OAAO,CAAC,YAAY;IAOjB,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC;CAahC;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAU9I;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEjF;AAED,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAA;AACrC,OAAO,EAAE,wCAAwC,EAAE,CAAA"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSignInputsFromImportableEd25519Key = exports.ResourcesModule = exports.DIDModule = exports.createCheqdSDK = exports.filterUnauthorizedMethods = exports.CheqdSDK = void 0;
|
|
4
|
+
const did_1 = require("./modules/did");
|
|
5
|
+
Object.defineProperty(exports, "DIDModule", { enumerable: true, get: function () { return did_1.DIDModule; } });
|
|
6
|
+
const resources_1 = require("./modules/resources");
|
|
7
|
+
Object.defineProperty(exports, "ResourcesModule", { enumerable: true, get: function () { return resources_1.ResourcesModule; } });
|
|
8
|
+
const _1 = require("./modules/_");
|
|
9
|
+
const registry_1 = require("./registry");
|
|
10
|
+
const signer_1 = require("./signer");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
Object.defineProperty(exports, "createSignInputsFromImportableEd25519Key", { enumerable: true, get: function () { return utils_1.createSignInputsFromImportableEd25519Key; } });
|
|
14
|
+
class CheqdSDK {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.protectedMethods = ['constructor', 'build', 'loadModules', 'loadRegistry'];
|
|
17
|
+
if (!(options === null || options === void 0 ? void 0 : options.wallet)) {
|
|
18
|
+
throw new Error('No wallet provided');
|
|
19
|
+
}
|
|
20
|
+
this.options = {
|
|
21
|
+
authorizedMethods: [],
|
|
22
|
+
network: types_1.CheqdNetwork.Testnet,
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
this.methods = {};
|
|
26
|
+
this.signer = new signer_1.CheqdSigningStargateClient(undefined, this.options.wallet, {});
|
|
27
|
+
}
|
|
28
|
+
async execute(method, ...params) {
|
|
29
|
+
if (!Object.keys(this.methods).includes(method)) {
|
|
30
|
+
throw new Error(`Method ${method} is not authorized`);
|
|
31
|
+
}
|
|
32
|
+
return await this.methods[method](...params, { sdk: this });
|
|
33
|
+
}
|
|
34
|
+
loadModules(modules) {
|
|
35
|
+
this.options.modules = this.options.modules.map((module) => (0, _1.instantiateCheqdSDKModule)(module, this.signer, { sdk: this }));
|
|
36
|
+
const methods = (0, _1.applyMixins)(this, modules);
|
|
37
|
+
this.methods = { ...this.methods, ...filterUnauthorizedMethods(methods, this.options.authorizedMethods || [], this.protectedMethods) };
|
|
38
|
+
for (const method of Object.keys(this.methods)) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
this[method] = async (...params) => {
|
|
41
|
+
return await this.execute(method, ...params);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
loadRegistry() {
|
|
47
|
+
const registryTypes = this.options.modules.map((module) => (0, _1.instantiateCheqdSDKModuleRegistryTypes)(module)).reduce((acc, types) => {
|
|
48
|
+
return [...acc, ...types];
|
|
49
|
+
});
|
|
50
|
+
return (0, registry_1.createDefaultCheqdRegistry)(registryTypes);
|
|
51
|
+
}
|
|
52
|
+
async build() {
|
|
53
|
+
const registry = this.loadRegistry();
|
|
54
|
+
this.signer = await signer_1.CheqdSigningStargateClient.connectWithSigner(this.options.rpcUrl, this.options.wallet, {
|
|
55
|
+
registry,
|
|
56
|
+
});
|
|
57
|
+
return this.loadModules(this.options.modules);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.CheqdSDK = CheqdSDK;
|
|
61
|
+
function filterUnauthorizedMethods(methods, authorizedMethods, protectedMethods) {
|
|
62
|
+
let _methods = Object.keys(methods);
|
|
63
|
+
if (authorizedMethods.length === 0)
|
|
64
|
+
return _methods
|
|
65
|
+
.filter(method => !protectedMethods.includes(method))
|
|
66
|
+
.reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {});
|
|
67
|
+
return _methods
|
|
68
|
+
.filter(method => authorizedMethods.includes(method) && !protectedMethods.includes(method))
|
|
69
|
+
.reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {});
|
|
70
|
+
}
|
|
71
|
+
exports.filterUnauthorizedMethods = filterUnauthorizedMethods;
|
|
72
|
+
async function createCheqdSDK(options) {
|
|
73
|
+
return await (new CheqdSDK(options)).build();
|
|
74
|
+
}
|
|
75
|
+
exports.createCheqdSDK = createCheqdSDK;
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,uCAAqE;AAsG5D,0FAtGA,eAAS,OAsGA;AArGlB,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ateClient } from '../signer';
|
|
4
|
+
import { IModuleMethodMap } from "../types";
|
|
5
|
+
export declare abstract class AbstractCheqdSDKModule {
|
|
6
|
+
_signer: CheqdSigningStargateClient;
|
|
7
|
+
methods: IModuleMethodMap;
|
|
8
|
+
readonly _protectedMethods: string[];
|
|
9
|
+
static readonly registryTypes: Iterable<[string, GeneratedType]>;
|
|
10
|
+
constructor(signer: CheqdSigningStargateClient);
|
|
11
|
+
abstract getRegistryTypes(): Iterable<[string, GeneratedType]>;
|
|
12
|
+
}
|
|
13
|
+
export declare type MinimalImportableCheqdSDKModule<T extends AbstractCheqdSDKModule> = Omit<T, '_signer' | '_protectedMethods' | 'registryTypes' | 'getRegistryTypes'>;
|
|
14
|
+
export declare function instantiateCheqdSDKModule<T extends new (...args: any[]) => T>(module: T, ...args: ConstructorParameters<T>): T;
|
|
15
|
+
export declare function instantiateCheqdSDKModuleRegistryTypes(module: any): Iterable<[string, GeneratedType]>;
|
|
16
|
+
export declare function applyMixins(derivedCtor: any, constructors: any[]): IModuleMethodMap;
|
|
17
|
+
export declare type CheqdExtension<K extends string, V = any> = {
|
|
18
|
+
[P in K]: (Record<P, V> & Partial<Record<Exclude<K, P>, never>>) extends infer O ? {
|
|
19
|
+
[Q in keyof O]: O[Q];
|
|
20
|
+
} : never;
|
|
21
|
+
}[K];
|
|
22
|
+
export declare type CheqdExtensions = CheqdExtension<'did' | 'resources', any>;
|
|
23
|
+
export declare const setupCheqdExtensions: (base: QueryClient) => CheqdExtensions;
|
|
24
|
+
//# sourceMappingURL=_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_.d.ts","sourceRoot":"","sources":["../../src/modules/_.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAY,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,E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AC,CAAC,CAAC;KAAE,GACxB,KAAK;CACP,CAAC,CAAC,CAAC,CAAA;AAEJ,oBAAY,eAAe,GAAG,cAAc,CAAC,KAAK,GAAG,WAAW,EAAE,GAAG,CAAC,CAAA;AAEtE,eAAO,MAAM,oBAAoB,SAAU,WAAW,KAAG,eAKxD,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupCheqdExtensions = exports.applyMixins = exports.instantiateCheqdSDKModuleRegistryTypes = exports.instantiateCheqdSDKModule = exports.AbstractCheqdSDKModule = void 0;
|
|
4
|
+
const did_1 = require("./did");
|
|
5
|
+
class AbstractCheqdSDKModule {
|
|
6
|
+
constructor(signer) {
|
|
7
|
+
this.methods = {};
|
|
8
|
+
this._protectedMethods = ['constructor', 'getRegistryTypes'];
|
|
9
|
+
if (!signer) {
|
|
10
|
+
throw new Error("signer is required");
|
|
11
|
+
}
|
|
12
|
+
this._signer = signer;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AbstractCheqdSDKModule = AbstractCheqdSDKModule;
|
|
16
|
+
AbstractCheqdSDKModule.registryTypes = [];
|
|
17
|
+
function instantiateCheqdSDKModule(module, ...args) {
|
|
18
|
+
return new module(...args);
|
|
19
|
+
}
|
|
20
|
+
exports.instantiateCheqdSDKModule = instantiateCheqdSDKModule;
|
|
21
|
+
function instantiateCheqdSDKModuleRegistryTypes(module) {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = module.registryTypes) !== null && _a !== void 0 ? _a : [];
|
|
24
|
+
}
|
|
25
|
+
exports.instantiateCheqdSDKModuleRegistryTypes = instantiateCheqdSDKModuleRegistryTypes;
|
|
26
|
+
function applyMixins(derivedCtor, constructors) {
|
|
27
|
+
let methods = {};
|
|
28
|
+
constructors.forEach((baseCtor) => {
|
|
29
|
+
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const property = baseCtor.prototype[name];
|
|
32
|
+
if (typeof property !== 'function' || derivedCtor.hasOwnProperty(name) || (derivedCtor === null || derivedCtor === void 0 ? void 0 : derivedCtor.protectedMethods.includes(name)) || ((_b = (_a = baseCtor.prototype) === null || _a === void 0 ? void 0 : _a._protectedMethods) === null || _b === void 0 ? void 0 : _b.includes(name)))
|
|
33
|
+
return;
|
|
34
|
+
methods = { ...methods, [name]: property };
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return methods;
|
|
38
|
+
}
|
|
39
|
+
exports.applyMixins = applyMixins;
|
|
40
|
+
const setupCheqdExtensions = (base) => {
|
|
41
|
+
return {
|
|
42
|
+
...(0, did_1.setupDidExtension)(base),
|
|
43
|
+
/** setupResourcesExtension(base) */
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
exports.setupCheqdExtensions = setupCheqdExtensions;
|
|
47
|
+
//# sourceMappingURL=_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_.js","sourceRoot":"","sources":["../../src/modules/_.ts"],"names":[],"mappings":";;;AAIA,+BAAoD;AAEpD,MAAsB,sBAAsB;IAM3C,YAAY,MAAkC;QAJ9C,YAAO,GAAqB,EAAE,CAAA;QACrB,sBAAiB,GAAa,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAA;QAIzE,IAAI,CAAC,MAAM,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;SACrC;QACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACtB,CAAC;;AAXF,wDAcC;AAVgB,oCAAa,GAAsC,EAAE,CAAA;AAgBtE,SAAgB,yBAAyB,CAAsC,MAAS,EAAE,GAAG,IAA8B;IAC1H,OAAO,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;AAC3B,CAAC;AAFD,8DAEC;AAED,SAAgB,sCAAsC,CAAC,MAAW;;IAC9D,OAAO,MAAA,MAAM,CAAC,aAAa,mCAAI,EAAE,CAAA;AACrC,CAAC;AAFD,wFAEC;AAED,SAAgB,WAAW,CAAC,WAAgB,EAAE,YAAmB;IAChE,IAAI,OAAO,GAAqB,EAAE,CAAA;IAElC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QACjC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;YAC/D,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YACzC,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,KAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA,KAAI,MAAA,MAAA,QAAQ,CAAC,SAAS,0CAAE,iBAAiB,0CAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;gBAAE,OAAM;YAEvL,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAA;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAA;AACf,CAAC;AAbD,kCAaC;AAUM,MAAM,oBAAoB,GAAG,CAAC,IAAiB,EAAmB,EAAE;IAC1E,OAAO;QACN,GAAG,IAAA,uBAAiB,EAAC,IAAI,CAAC;QAC1B,oCAAoC;KACpC,CAAA;AACF,CAAC,CAAA;AALY,QAAA,oBAAoB,wBAKhC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DeliverTxResponse, QueryClient } from "@cosmjs/stargate";
|
|
2
|
+
import { CheqdExtension, AbstractCheqdSDKModule, MinimalImportableCheqdSDKModule } from "./_";
|
|
3
|
+
import { CheqdSigningStargateClient } from "../signer";
|
|
4
|
+
import { DidStdFee, IContext, ISignInputs } from "../types";
|
|
5
|
+
import { MsgCreateDid, MsgCreateDidPayload, MsgCreateDidResponse, MsgUpdateDid, MsgUpdateDidPayload, MsgUpdateDidResponse } from "@cheqd/ts-proto/cheqd/v1/tx";
|
|
6
|
+
import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing";
|
|
7
|
+
export declare const typeUrlMsgCreateDid: string;
|
|
8
|
+
export declare const typeUrlMsgCreateDidResponse: string;
|
|
9
|
+
export declare const typeUrlMsgUpdateDid: string;
|
|
10
|
+
export declare const typeUrlMsgUpdateDidResponse: string;
|
|
11
|
+
export interface MsgCreateDidEncodeObject extends EncodeObject {
|
|
12
|
+
readonly typeUrl: typeof typeUrlMsgCreateDid;
|
|
13
|
+
readonly value: Partial<MsgCreateDid>;
|
|
14
|
+
}
|
|
15
|
+
export declare function isMsgCreateDidEncodeObject(obj: EncodeObject): obj is MsgCreateDidEncodeObject;
|
|
16
|
+
export interface MsgCreateDidResponseEncodeObject extends EncodeObject {
|
|
17
|
+
readonly typeUrl: typeof typeUrlMsgCreateDidResponse;
|
|
18
|
+
readonly value: Partial<MsgCreateDidResponse>;
|
|
19
|
+
}
|
|
20
|
+
export declare function MsgCreateDidResponseEncodeObject(obj: EncodeObject): obj is MsgCreateDidResponseEncodeObject;
|
|
21
|
+
export interface MsgUpdateDidEncodeObject extends EncodeObject {
|
|
22
|
+
readonly typeUrl: typeof typeUrlMsgUpdateDid;
|
|
23
|
+
readonly value: Partial<MsgUpdateDid>;
|
|
24
|
+
}
|
|
25
|
+
export declare function MsgUpdateDidEncodeObject(obj: EncodeObject): obj is MsgUpdateDidEncodeObject;
|
|
26
|
+
export interface MsgUpdateDidResponseEncodeObject extends EncodeObject {
|
|
27
|
+
readonly typeUrl: typeof typeUrlMsgUpdateDidResponse;
|
|
28
|
+
readonly value: Partial<MsgUpdateDidResponse>;
|
|
29
|
+
}
|
|
30
|
+
export declare function MsgUpdateDidResponseEncodeObject(obj: EncodeObject): obj is MsgUpdateDidResponseEncodeObject;
|
|
31
|
+
export declare class DIDModule extends AbstractCheqdSDKModule {
|
|
32
|
+
static readonly registryTypes: Iterable<[string, GeneratedType]>;
|
|
33
|
+
constructor(signer: CheqdSigningStargateClient);
|
|
34
|
+
getRegistryTypes(): Iterable<[string, GeneratedType]>;
|
|
35
|
+
createDidTx(signInputs: ISignInputs[], didPayload: Partial<MsgCreateDidPayload>, address: string, fee: DidStdFee | 'auto' | number, memo?: string, context?: IContext): Promise<DeliverTxResponse>;
|
|
36
|
+
updateDidTx(signInputs: ISignInputs[], didPayload: Partial<MsgUpdateDidPayload>, address: string, fee: DidStdFee | 'auto' | number, memo?: string, context?: IContext): Promise<DeliverTxResponse>;
|
|
37
|
+
}
|
|
38
|
+
export declare type MinimalImportableDIDModule = MinimalImportableCheqdSDKModule<DIDModule>;
|
|
39
|
+
export interface DidExtension extends CheqdExtension<string, {}> {
|
|
40
|
+
did: {};
|
|
41
|
+
}
|
|
42
|
+
export declare const setupDidExtension: (base: QueryClient) => DidExtension;
|
|
43
|
+
//# sourceMappingURL=did.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../src/modules/did.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE1F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,KAAK,CAAA;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAmB,MAAM,6BAA6B,CAAA;AAC/K,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAEnE,eAAO,MAA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AK5D;gBAEQ,MAAM,EAAE,0BAA0B;IAQpC,gBAAgB,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAIzD,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA0BlM,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAyBxM;AAED,oBAAY,0BAA0B,GAAG,+BAA+B,CAAC,SAAS,CAAC,CAAA;AAEnF,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC;IAC/D,GAAG,EAAE,EAAE,CAAA;CACP;AAED,eAAO,MAAM,iBAAiB,SAAU,WAAW,KAAG,YAUrD,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupDidExtension = exports.DIDModule = exports.MsgUpdateDidResponseEncodeObject = exports.MsgUpdateDidEncodeObject = exports.MsgCreateDidResponseEncodeObject = exports.isMsgCreateDidEncodeObject = exports.typeUrlMsgUpdateDidResponse = exports.typeUrlMsgUpdateDid = exports.typeUrlMsgCreateDidResponse = exports.typeUrlMsgCreateDid = void 0;
|
|
4
|
+
const stargate_1 = require("@cosmjs/stargate");
|
|
5
|
+
/* import { QueryClientImpl } from '@cheqd/ts-proto/cheqd/v1/query' */
|
|
6
|
+
const _1 = require("./_");
|
|
7
|
+
const tx_1 = require("@cheqd/ts-proto/cheqd/v1/tx");
|
|
8
|
+
exports.typeUrlMsgCreateDid = `/${tx_1.protobufPackage}.MsgCreateDid`;
|
|
9
|
+
exports.typeUrlMsgCreateDidResponse = `/${tx_1.protobufPackage}.MsgCreateDidResponse`;
|
|
10
|
+
exports.typeUrlMsgUpdateDid = `/${tx_1.protobufPackage}.MsgUpdateDid`;
|
|
11
|
+
exports.typeUrlMsgUpdateDidResponse = `/${tx_1.protobufPackage}.MsgUpdateDidResponse`;
|
|
12
|
+
function isMsgCreateDidEncodeObject(obj) {
|
|
13
|
+
return obj.typeUrl === exports.typeUrlMsgCreateDid;
|
|
14
|
+
}
|
|
15
|
+
exports.isMsgCreateDidEncodeObject = isMsgCreateDidEncodeObject;
|
|
16
|
+
function MsgCreateDidResponseEncodeObject(obj) {
|
|
17
|
+
return obj.typeUrl === exports.typeUrlMsgCreateDidResponse;
|
|
18
|
+
}
|
|
19
|
+
exports.MsgCreateDidResponseEncodeObject = MsgCreateDidResponseEncodeObject;
|
|
20
|
+
function MsgUpdateDidEncodeObject(obj) {
|
|
21
|
+
return obj.typeUrl === exports.typeUrlMsgUpdateDid;
|
|
22
|
+
}
|
|
23
|
+
exports.MsgUpdateDidEncodeObject = MsgUpdateDidEncodeObject;
|
|
24
|
+
function MsgUpdateDidResponseEncodeObject(obj) {
|
|
25
|
+
return obj.typeUrl === exports.typeUrlMsgUpdateDidResponse;
|
|
26
|
+
}
|
|
27
|
+
exports.MsgUpdateDidResponseEncodeObject = MsgUpdateDidResponseEncodeObject;
|
|
28
|
+
class DIDModule extends _1.AbstractCheqdSDKModule {
|
|
29
|
+
constructor(signer) {
|
|
30
|
+
super(signer);
|
|
31
|
+
this.methods = {
|
|
32
|
+
createDidTx: this.createDidTx.bind(this),
|
|
33
|
+
updateDidTx: this.updateDidTx.bind(this)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
getRegistryTypes() {
|
|
37
|
+
return DIDModule.registryTypes;
|
|
38
|
+
}
|
|
39
|
+
async createDidTx(signInputs, didPayload, address, fee, memo, context) {
|
|
40
|
+
if (!this._signer) {
|
|
41
|
+
this._signer = context.sdk.signer;
|
|
42
|
+
}
|
|
43
|
+
const payload = tx_1.MsgCreateDidPayload.fromPartial(didPayload);
|
|
44
|
+
const signatures = await this._signer.signCreateDidTx(signInputs, payload);
|
|
45
|
+
const value = {
|
|
46
|
+
payload,
|
|
47
|
+
signatures
|
|
48
|
+
};
|
|
49
|
+
const createDidMsg = {
|
|
50
|
+
typeUrl: exports.typeUrlMsgCreateDid,
|
|
51
|
+
value
|
|
52
|
+
};
|
|
53
|
+
return this._signer.signAndBroadcast(address, [createDidMsg], fee, memo);
|
|
54
|
+
}
|
|
55
|
+
async updateDidTx(signInputs, didPayload, address, fee, memo, context) {
|
|
56
|
+
if (!this._signer) {
|
|
57
|
+
this._signer = context.sdk.signer;
|
|
58
|
+
}
|
|
59
|
+
const payload = tx_1.MsgUpdateDidPayload.fromPartial(didPayload);
|
|
60
|
+
const signatures = await this._signer.signUpdateDidTx(signInputs, payload);
|
|
61
|
+
const value = {
|
|
62
|
+
payload,
|
|
63
|
+
signatures
|
|
64
|
+
};
|
|
65
|
+
const updateDidMsg = {
|
|
66
|
+
typeUrl: exports.typeUrlMsgUpdateDid,
|
|
67
|
+
value
|
|
68
|
+
};
|
|
69
|
+
return this._signer.signAndBroadcast(address, [updateDidMsg], fee, memo);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.DIDModule = DIDModule;
|
|
73
|
+
DIDModule.registryTypes = [
|
|
74
|
+
[exports.typeUrlMsgCreateDid, tx_1.MsgCreateDid],
|
|
75
|
+
[exports.typeUrlMsgCreateDidResponse, tx_1.MsgCreateDidResponse],
|
|
76
|
+
[exports.typeUrlMsgUpdateDid, tx_1.MsgUpdateDid],
|
|
77
|
+
[exports.typeUrlMsgUpdateDidResponse, tx_1.MsgUpdateDidResponse],
|
|
78
|
+
];
|
|
79
|
+
const setupDidExtension = (base) => {
|
|
80
|
+
const rpc = (0, stargate_1.createProtobufRpcClient)(base);
|
|
81
|
+
/* const queryService = new QueryClientImpl(rpc) */
|
|
82
|
+
return {
|
|
83
|
+
did: {
|
|
84
|
+
//...
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
exports.setupDidExtension = setupDidExtension;
|
|
89
|
+
//# sourceMappingURL=did.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did.js","sourceRoot":"","sources":["../../src/modules/did.ts"],"names":[],"mappings":";;;AAAA,+CAA0F;AAC1F,sEAAsE;AACtE,0BAA6F;AAG7F,oDAA+K;AAGlK,QAAA,mBAAmB,GAAG,IAAI,oBAAe,eAAe,CAAA;AACxD,QAAA,2BAA2B,GAAG,IAAI,oBAAe,uBAAuB,CAAA;AACxE,QAAA,mBAAmB,GAAG,IAAI,oBAAe,eAAe,CAAA;AACxD,QAAA,2BAA2B,GAAG,IAAI,oBAAe,uBAAuB,CAAA;AAOrF,SAAgB,0BAA0B,CAAC,GAAiB;IAC3D,OAAO,GAAG,CAAC,OAAO,KAAK,2BAAmB,CAAA;AAC3C,CAAC;AAFD,gEAEC;AAOD,SAAgB,gCAAgC,CAAC,GAAiB;IACjE,OAAO,GAAG,CAAC,OAAO,KAAK,mCAA2B,CAAA;AACnD,CAAC;AAFD,4EAEC;AAOD,SAAgB,wBAAwB,CAAC,GAAiB;IACzD,OAAO,GAAG,CAAC,OAAO,KAAK,2BAAmB,CAAA;AAC3C,CAAC;AAFD,4DAEC;AAOD,SAAgB,gCAAgC,CAAC,GAAiB;IACjE,OAAO,GAAG,CAAC,OAAO,KAAK,mCAA2B,CAAA;AACnD,CAAC;AAFD,4EAEC;AAED,MAAa,SAAU,SAAQ,yBAAsB;IAQpD,YAAY,MAAkC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAA;Q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CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAE1E,MAAM,KAAK,GAAiB;YAC3B,OAAO;YACP,UAAU;SACV,CAAA;QAED,MAAM,YAAY,GAA6B;YAC9C,OAAO,EAAE,2BAAmB;YAC5B,KAAK;SACL,CAAA;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CACnC,OAAO,EACP,CAAC,YAAY,CAAC,EACd,GAAG,EACH,IAAI,CACJ,CAAA;IACF,CAAC;;AAtEF,8BAuEC;AAtEgB,uBAAa,GAAsC;IAC5D,CAAC,2BAAmB,EAAE,iBAAY,CAAC;IACnC,CAAC,mCAA2B,EAAE,yBAAoB,CAAC;IACnD,CAAC,2BAAmB,EAAE,iBAAY,CAAC;IACnC,CAAC,mCAA2B,EAAE,yBAAoB,CAAC;CACtD,CAAA;AAyEE,MAAM,iBAAiB,GAAG,CAAC,IAAiB,EAAgB,EAAE;IACpE,MAAM,GAAG,GAAG,IAAA,kCAAuB,EAAC,IAAI,CAAC,CAAA;IAEzC,mDAAmD;IAEnD,OAAO;QACN,GAAG,EAAE;QACJ,KAAK;SACL;KACD,CAAA;AACF,CAAC,CAAA;AAVY,QAAA,iBAAiB,qBAU7B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AbstractCheqdSDKModule, MinimalImportableCheqdSDKModule } from "./_";
|
|
2
|
+
import { CheqdSigningStargateClient } from "../signer";
|
|
3
|
+
import { GeneratedType } from "@cosmjs/proto-signing";
|
|
4
|
+
export declare class ResourcesModule extends AbstractCheqdSDKModule {
|
|
5
|
+
registryTypes: Iterable<[string, GeneratedType]>;
|
|
6
|
+
constructor(signer: CheqdSigningStargateClient);
|
|
7
|
+
getRegistryTypes(): Iterable<[string, GeneratedType]>;
|
|
8
|
+
}
|
|
9
|
+
export declare type MinimalImportableResourcesModule = MinimalImportableCheqdSDKModule<ResourcesModule>;
|
|
10
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/modules/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAGrD,qBAAa,eAAgB,SAAQ,sBAAsB;IAC1D,aAAa,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAK;gBAEzC,MAAM,EAAE,0BAA0B;IAIvC,gBAAgB,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAG5D;AAED,oBAAY,gCAAgC,GAAG,+BAA+B,CAAC,eAAe,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourcesModule = void 0;
|
|
4
|
+
const _1 = require("./_");
|
|
5
|
+
class ResourcesModule extends _1.AbstractCheqdSDKModule {
|
|
6
|
+
constructor(signer) {
|
|
7
|
+
super(signer);
|
|
8
|
+
this.registryTypes = [];
|
|
9
|
+
}
|
|
10
|
+
getRegistryTypes() {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ResourcesModule = ResourcesModule;
|
|
15
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/modules/resources.ts"],"names":[],"mappings":";;;AAAA,0BAA6E;AAK7E,MAAa,eAAgB,SAAQ,yBAAsB;IAG1D,YAAY,MAAkC;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAA;QAHd,kBAAa,GAAsC,EAAE,CAAA;IAIrD,CAAC;IAEM,gBAAgB;QACtB,OAAO,EAAE,CAAA;IACV,CAAC;CACD;AAVD,0CAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,aAAa,EACb,MAAM,uBAAuB,CAAA;AAM9B,wBAAgB,0BAA0B,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,GAAG,QAAQ,CAGpG;AAED,eAAO,MAAM,aAAa,UAAqC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheqdRegistry = exports.createDefaultCheqdRegistry = void 0;
|
|
4
|
+
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
5
|
+
const stargate_1 = require("@cosmjs/stargate");
|
|
6
|
+
function createDefaultCheqdRegistry(customTypes) {
|
|
7
|
+
if (!customTypes)
|
|
8
|
+
customTypes = [];
|
|
9
|
+
return new proto_signing_1.Registry([...stargate_1.defaultRegistryTypes, ...customTypes]);
|
|
10
|
+
}
|
|
11
|
+
exports.createDefaultCheqdRegistry = createDefaultCheqdRegistry;
|
|
12
|
+
exports.CheqdRegistry = new proto_signing_1.Registry(stargate_1.defaultRegistryTypes);
|
|
13
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";;;AAAA,yDAG8B;AAE9B,+CAEyB;AAEzB,SAAgB,0BAA0B,CAAC,WAA+C;IACzF,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,EAAE,CAAC;IACnC,OAAO,IAAI,wBAAQ,CAAC,CAAC,GAAG,+BAAoB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAA;AAC/D,CAAC;AAHD,gEAGC;AAEY,QAAA,aAAa,GAAG,IAAI,wBAAQ,CAAC,+BAAoB,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CheqdExtensions } from './modules/_';
|
|
2
|
+
import { EncodeObject, OfflineSigner } from "@cosmjs/proto-signing";
|
|
3
|
+
import { DeliverTxResponse, GasPrice, HttpEndpoint, SigningStargateClient, SigningStargateClientOptions, SignerData } from "@cosmjs/stargate";
|
|
4
|
+
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
|
5
|
+
import { MsgCreateDidPayload, SignInfo, MsgUpdateDidPayload } from '@cheqd/ts-proto/cheqd/v1/tx';
|
|
6
|
+
import { DidStdFee, ISignInputs, TSignerAlgo } from './types';
|
|
7
|
+
import { VerificationMethod } from '@cheqd/ts-proto/cheqd/v1/did';
|
|
8
|
+
import { Signer } from 'did-jwt';
|
|
9
|
+
import { SignerInfo, TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
10
|
+
import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing';
|
|
11
|
+
import { Any } from 'cosmjs-types/google/protobuf/any';
|
|
12
|
+
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
|
|
13
|
+
export declare function calculateDidFee(gasLimit: number, gasPrice: string | GasPrice): DidStdFee;
|
|
14
|
+
export declare function makeSignerInfos(signers: ReadonlyArray<{
|
|
15
|
+
readonly pubkey: Any;
|
|
16
|
+
readonly sequence: number;
|
|
17
|
+
}>, signMode: SignMode): SignerInfo[];
|
|
18
|
+
export declare function makeDidAuthInfoBytes(signers: ReadonlyArray<{
|
|
19
|
+
readonly pubkey: Any;
|
|
20
|
+
readonly sequence: number;
|
|
21
|
+
}>, feeAmount: readonly Coin[], gasLimit: number, feePayer: string, signMode?: SignMode): Uint8Array;
|
|
22
|
+
export declare class CheqdSigningStargateClient extends SigningStargateClient {
|
|
23
|
+
readonly cheqdExtensions: CheqdExtensions | undefined;
|
|
24
|
+
private didSigners;
|
|
25
|
+
private readonly _gasPrice;
|
|
26
|
+
private readonly _signer;
|
|
27
|
+
static connectWithSigner(endpoint: string | HttpEndpoint, signer: OfflineSigner, options?: SigningStargateClientOptions | undefined): Promise<CheqdSigningStargateClient>;
|
|
28
|
+
constructor(tmClient: Tendermint34Client | undefined, signer: OfflineSigner, options?: SigningStargateClientOptions);
|
|
29
|
+
signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: DidStdFee | "auto" | number, memo?: string): Promise<DeliverTxResponse>;
|
|
30
|
+
sign(signerAddress: string, messages: readonly EncodeObject[], fee: DidStdFee, memo: string, explicitSignerData?: SignerData): Promise<TxRaw>;
|
|
31
|
+
private _signDirect;
|
|
32
|
+
checkDidSigners(verificationMethods?: Partial<VerificationMethod>[]): Promise<TSignerAlgo>;
|
|
33
|
+
getDidSigner(verificationMethodId: string, verificationMethods: Partial<VerificationMethod>[]): Promise<(secretKey: Uint8Array) => Signer>;
|
|
34
|
+
signCreateDidTx(signInputs: ISignInputs[], payload: MsgCreateDidPayload): Promise<SignInfo[]>;
|
|
35
|
+
signUpdateDidTx(signInputs: ISignInputs[], payload: MsgUpdateDidPayload): Promise<SignInfo[]>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAyB,aAAa,EAAiD,MAAM,uBAAuB,CAAA;AACzI,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAe,qBAAqB,EAAE,4BAA4B,EAAgB,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxK,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC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AAY,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,4BAA4B,GAAG,SAAS,GAAG,OAAO,CAAC,0BAA0B,CAAC;gBASrL,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EACxC,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,4BAAiC;IAYrC,gBAAgB,CACrB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,GAAG,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,EAChC,IAAI,SAAK,GACP,OAAO,CAAC,iBAAiB,CAAC;IAkBhB,IAAI,CAChB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,MAAM,EACZ,kBAAkB,CAAC,EAAE,UAAU,GAC7B,OAAO,CAAC,KAAK,CAAC;YAsBH,WAAW;IAkCnB,eAAe,CAAC,mBAAmB,GAAE,OAAO,CAAC,kBAAkB,CAAC,EAAO,GAAG,OAAO,CAAC,WAAW,CAAC;IAiB9F,YAAY,CAAC,oBAAoB,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,SAAS,EAAE,UAAU,KAAK,MAAM,CAAC;IAS1I,eAAe,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAe7F,eAAe,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAcnG"}
|
package/build/signer.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CheqdSigningStargateClient = exports.makeDidAuthInfoBytes = exports.makeSignerInfos = exports.calculateDidFee = void 0;
|
|
7
|
+
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
8
|
+
const stargate_1 = require("@cosmjs/stargate");
|
|
9
|
+
const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
10
|
+
const registry_1 = require("./registry");
|
|
11
|
+
const tx_1 = require("@cheqd/ts-proto/cheqd/v1/tx");
|
|
12
|
+
const types_1 = require("./types");
|
|
13
|
+
const did_jwt_1 = require("did-jwt");
|
|
14
|
+
const uint8arrays_1 = require("uint8arrays");
|
|
15
|
+
const utils_1 = require("@cosmjs/utils");
|
|
16
|
+
const amino_1 = require("@cosmjs/amino");
|
|
17
|
+
const math_1 = require("@cosmjs/math");
|
|
18
|
+
const encoding_1 = require("@cosmjs/encoding");
|
|
19
|
+
const tx_2 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
|
|
20
|
+
const signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
|
|
21
|
+
const long_1 = __importDefault(require("long"));
|
|
22
|
+
function calculateDidFee(gasLimit, gasPrice) {
|
|
23
|
+
return (0, stargate_1.calculateFee)(gasLimit, gasPrice);
|
|
24
|
+
}
|
|
25
|
+
exports.calculateDidFee = calculateDidFee;
|
|
26
|
+
function makeSignerInfos(signers, signMode) {
|
|
27
|
+
return signers.map(({ pubkey, sequence }) => ({
|
|
28
|
+
publicKey: pubkey,
|
|
29
|
+
modeInfo: {
|
|
30
|
+
single: { mode: signMode },
|
|
31
|
+
},
|
|
32
|
+
sequence: long_1.default.fromNumber(sequence),
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
exports.makeSignerInfos = makeSignerInfos;
|
|
36
|
+
function makeDidAuthInfoBytes(signers, feeAmount, gasLimit, feePayer, signMode = signing_1.SignMode.SIGN_MODE_DIRECT) {
|
|
37
|
+
const authInfo = {
|
|
38
|
+
signerInfos: makeSignerInfos(signers, signMode),
|
|
39
|
+
fee: {
|
|
40
|
+
amount: [...feeAmount],
|
|
41
|
+
gasLimit: long_1.default.fromNumber(gasLimit),
|
|
42
|
+
payer: feePayer
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//* There is a `Long` type incompatibility in the protobuf library that causes the following line to throw an error. No actual type mismatch is ever encountered.
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
return tx_2.AuthInfo.encode(tx_2.AuthInfo.fromPartial(authInfo)).finish();
|
|
48
|
+
}
|
|
49
|
+
exports.makeDidAuthInfoBytes = makeDidAuthInfoBytes;
|
|
50
|
+
class CheqdSigningStargateClient extends stargate_1.SigningStargateClient {
|
|
51
|
+
constructor(tmClient, signer, options = {}) {
|
|
52
|
+
super(tmClient, signer, options);
|
|
53
|
+
this.didSigners = {};
|
|
54
|
+
this._signer = signer;
|
|
55
|
+
if (options.gasPrice)
|
|
56
|
+
this._gasPrice = options.gasPrice;
|
|
57
|
+
/** GRPC Connection */
|
|
58
|
+
/* if (tmClient) {
|
|
59
|
+
this.cheqdExtensions = QueryClient.withExtensions(tmClient, setupCheqdExtensions)
|
|
60
|
+
} */
|
|
61
|
+
}
|
|
62
|
+
static async connectWithSigner(endpoint, signer, options) {
|
|
63
|
+
const tmClient = await tendermint_rpc_1.Tendermint34Client.connect(endpoint);
|
|
64
|
+
return new CheqdSigningStargateClient(tmClient, signer, {
|
|
65
|
+
registry: (options === null || options === void 0 ? void 0 : options.registry) ? options.registry : (0, registry_1.createDefaultCheqdRegistry)(),
|
|
66
|
+
...options
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async signAndBroadcast(signerAddress, messages, fee, memo = "") {
|
|
70
|
+
let usedFee;
|
|
71
|
+
if (fee == "auto" || typeof fee === "number") {
|
|
72
|
+
(0, utils_1.assertDefined)(this._gasPrice, "Gas price must be set in the client options when auto gas is used.");
|
|
73
|
+
const gasEstimation = await this.simulate(signerAddress, messages, memo);
|
|
74
|
+
const multiplier = typeof fee === "number" ? fee : 1.3;
|
|
75
|
+
usedFee = calculateDidFee(Math.round(gasEstimation * multiplier), this._gasPrice);
|
|
76
|
+
usedFee.payer = signerAddress;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
usedFee = fee;
|
|
80
|
+
(0, utils_1.assertDefined)(usedFee.payer, "Payer address must be set when fee is not auto.");
|
|
81
|
+
signerAddress = usedFee.payer;
|
|
82
|
+
}
|
|
83
|
+
const txRaw = await this.sign(signerAddress, messages, usedFee, memo);
|
|
84
|
+
const txBytes = tx_2.TxRaw.encode(txRaw).finish();
|
|
85
|
+
return this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs);
|
|
86
|
+
}
|
|
87
|
+
async sign(signerAddress, messages, fee, memo, explicitSignerData) {
|
|
88
|
+
let signerData;
|
|
89
|
+
if (explicitSignerData) {
|
|
90
|
+
signerData = explicitSignerData;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const { accountNumber, sequence } = await this.getSequence(signerAddress);
|
|
94
|
+
const chainId = await this.getChainId();
|
|
95
|
+
signerData = {
|
|
96
|
+
accountNumber: accountNumber,
|
|
97
|
+
sequence: sequence,
|
|
98
|
+
chainId: chainId,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return this._signDirect(signerAddress, messages, fee, memo, signerData);
|
|
102
|
+
// TODO: override signAmino as well
|
|
103
|
+
/* return isOfflineDirectSigner(this._signer)
|
|
104
|
+
? this._signDirect(signerAddress, messages, fee, memo, signerData)
|
|
105
|
+
: this._signAmino(signerAddress, messages, fee, memo, signerData) */
|
|
106
|
+
}
|
|
107
|
+
async _signDirect(signerAddress, messages, fee, memo, { accountNumber, sequence, chainId }) {
|
|
108
|
+
(0, utils_1.assert)((0, proto_signing_1.isOfflineDirectSigner)(this._signer));
|
|
109
|
+
const accountFromSigner = (await this._signer.getAccounts()).find((account) => account.address === signerAddress);
|
|
110
|
+
if (!accountFromSigner) {
|
|
111
|
+
throw new Error("Failed to retrieve account from signer");
|
|
112
|
+
}
|
|
113
|
+
const pubkey = (0, proto_signing_1.encodePubkey)((0, amino_1.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
|
|
114
|
+
const txBodyEncodeObject = {
|
|
115
|
+
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
116
|
+
value: {
|
|
117
|
+
messages: messages,
|
|
118
|
+
memo: memo,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const txBodyBytes = this.registry.encode(txBodyEncodeObject);
|
|
122
|
+
const gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
|
|
123
|
+
const authInfoBytes = makeDidAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, fee.payer);
|
|
124
|
+
const signDoc = (0, proto_signing_1.makeSignDoc)(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
125
|
+
const { signature, signed } = await this._signer.signDirect(signerAddress, signDoc);
|
|
126
|
+
return tx_2.TxRaw.fromPartial({
|
|
127
|
+
bodyBytes: signed.bodyBytes,
|
|
128
|
+
authInfoBytes: signed.authInfoBytes,
|
|
129
|
+
signatures: [(0, encoding_1.fromBase64)(signature.signature)],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async checkDidSigners(verificationMethods = []) {
|
|
133
|
+
if (verificationMethods.length === 0) {
|
|
134
|
+
throw new Error('No verification methods provided');
|
|
135
|
+
}
|
|
136
|
+
verificationMethods.forEach((verificationMethod) => {
|
|
137
|
+
var _a, _b, _c;
|
|
138
|
+
if (!Object.values(types_1.VerificationMethods).includes((_a = verificationMethod.type) !== null && _a !== void 0 ? _a : '')) {
|
|
139
|
+
throw new Error(`Unsupported verification method type: ${verificationMethod.type}`);
|
|
140
|
+
}
|
|
141
|
+
if (!this.didSigners[(_b = verificationMethod.type) !== null && _b !== void 0 ? _b : '']) {
|
|
142
|
+
this.didSigners[(_c = verificationMethod.type) !== null && _c !== void 0 ? _c : ''] = did_jwt_1.EdDSASigner;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return this.didSigners;
|
|
146
|
+
}
|
|
147
|
+
async getDidSigner(verificationMethodId, verificationMethods) {
|
|
148
|
+
var _a;
|
|
149
|
+
await this.checkDidSigners(verificationMethods);
|
|
150
|
+
const verificationMethod = (_a = verificationMethods.find(method => method.id === verificationMethodId)) === null || _a === void 0 ? void 0 : _a.type;
|
|
151
|
+
if (!verificationMethod) {
|
|
152
|
+
throw new Error(`Verification method for ${verificationMethodId} not found`);
|
|
153
|
+
}
|
|
154
|
+
return this.didSigners[verificationMethod];
|
|
155
|
+
}
|
|
156
|
+
async signCreateDidTx(signInputs, payload) {
|
|
157
|
+
await this.checkDidSigners(payload === null || payload === void 0 ? void 0 : payload.verificationMethod);
|
|
158
|
+
const signBytes = tx_1.MsgCreateDidPayload.encode(payload).finish();
|
|
159
|
+
const signInfos = await Promise.all(signInputs.map(async (signInput) => {
|
|
160
|
+
return {
|
|
161
|
+
verificationMethodId: signInput.verificationMethodId,
|
|
162
|
+
// TODO: We can't rely on `payload.verificationMethod` here because `CreateResourceTx` doesn't have it
|
|
163
|
+
signature: (0, uint8arrays_1.toString)((0, did_jwt_1.base64ToBytes)((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))((0, did_jwt_1.hexToBytes)(signInput.privateKeyHex))(signBytes))), 'base64pad')
|
|
164
|
+
};
|
|
165
|
+
}));
|
|
166
|
+
return signInfos;
|
|
167
|
+
}
|
|
168
|
+
async signUpdateDidTx(signInputs, payload) {
|
|
169
|
+
await this.checkDidSigners(payload === null || payload === void 0 ? void 0 : payload.verificationMethod);
|
|
170
|
+
const signBytes = tx_1.MsgUpdateDidPayload.encode(payload).finish();
|
|
171
|
+
const signInfos = await Promise.all(signInputs.map(async (signInput) => {
|
|
172
|
+
return {
|
|
173
|
+
verificationMethodId: signInput.verificationMethodId,
|
|
174
|
+
// TODO: We can't rely on `payload.verificationMethod` here because `CreateResourceTx` doesn't have it
|
|
175
|
+
signature: (0, uint8arrays_1.toString)((0, did_jwt_1.base64ToBytes)((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))((0, did_jwt_1.hexToBytes)(signInput.privateKeyHex))(signBytes))), 'base64pad')
|
|
176
|
+
};
|
|
177
|
+
}));
|
|
178
|
+
return signInfos;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.CheqdSigningStargateClient = CheqdSigningStargateClient;
|
|
182
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":";;;;;;AACA,yDAAyI;AACzI,+CAAwK;AACxK,2DAA2D;AAC3D,yCAAuD;AACvD,oDAAiG;AACjG,mCAAkF;AAElF,qCAAwE;AACxE,6CAAsC;AACtC,yCAAqD;AACrD,yCAAqD;AACrD,uCAAoC;AACpC,+CAA6C;AAC7C,0DAA+E;AAC/E,4EAAyE;AAGzE,gDAAuB;AAEvB,SAAgB,eAAe,CAAC,QAAgB,EAAE,QAA2B;IAC5E,OAAO,IAAA,uBAAY,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAC9B,OAA2E,EAC3E,QAAkB;IAElB,OAAO,OAAO,CAAC,GAAG,CACjB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAc,EAAE,CAAC,CAAC;QACtC,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE;YACT,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;QACD,QAAQ,EAAE,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;KACnC,CAAC,CACF,CAAC;AACH,CAAC;AAbD,0CAaC;AAED,SAAgB,oBAAoB,CACnC,OAA2E,EAC3E,SAA0B,EAC1B,QAAgB,EAChB,QAAgB,EAChB,QAAQ,GAAG,kBAAQ,CAAC,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CAAC,CAAA;QAEH,OAAO,SAAS,CAAA;IACjB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,UAAyB,EAAE,OAA4B;QAC5E,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,kBAAkB,CAAC,CAAA;QAEvD,MAAM,SAAS,GAAG,wBAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAA;QAC9D,MAAM,SAAS,GAAe,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAClF,OAAO;gBACN,oBAAoB,EAAE,SAAS,CAAC,oBAAoB;gBACpD,sGAAsG;gBACtG,SAAS,EAAE,IAAA,sBAAQ,EAAC,IAAA,uBAAa,EAAC,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,oBAAoB,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAA,oBAAU,EAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAW,CAAC,EAAE,WAAW,CAAC;aACxM,CAAA;QACF,CAAC,CAAC,CAAC,CAAA;QAEH,OAAO,SAAS,CAAA;IACjB,CAAC;CACD;AAzKD,gEAyKC"}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CheqdSDK } from ".";
|
|
2
|
+
import { Signer } from 'did-jwt';
|
|
3
|
+
import { Coin } from "@cosmjs/proto-signing";
|
|
4
|
+
export declare enum CheqdNetwork {
|
|
5
|
+
Mainnet = "mainnet",
|
|
6
|
+
Testnet = "testnet"
|
|
7
|
+
}
|
|
8
|
+
export interface IModuleMethod {
|
|
9
|
+
(...args: any[]): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export interface IModuleMethodMap extends Record<string, IModuleMethod> {
|
|
12
|
+
}
|
|
13
|
+
export interface IContext {
|
|
14
|
+
sdk: CheqdSDK;
|
|
15
|
+
}
|
|
16
|
+
export declare enum VerificationMethods {
|
|
17
|
+
Base58 = "Ed25519VerificationKey2020",
|
|
18
|
+
JWK = "JsonWebKey2020"
|
|
19
|
+
}
|
|
20
|
+
export declare enum MethodSpecificIdAlgo {
|
|
21
|
+
Base58 = "base58btc",
|
|
22
|
+
Uuid = "uuid"
|
|
23
|
+
}
|
|
24
|
+
export declare type TSignerAlgo = {
|
|
25
|
+
[key in VerificationMethods as string]?: (secretKey: Uint8Array) => Signer;
|
|
26
|
+
};
|
|
27
|
+
export interface ISignInputs {
|
|
28
|
+
verificationMethodId: string;
|
|
29
|
+
privateKeyHex: string;
|
|
30
|
+
}
|
|
31
|
+
export interface IKeyPair {
|
|
32
|
+
publicKey: string;
|
|
33
|
+
privateKey: string;
|
|
34
|
+
}
|
|
35
|
+
export interface IKeyValuePair {
|
|
36
|
+
key: string;
|
|
37
|
+
value: any;
|
|
38
|
+
}
|
|
39
|
+
export declare type TVerificationKeyPrefix = string;
|
|
40
|
+
export declare type TVerificationKey<K extends TVerificationKeyPrefix, N extends number> = `${K}-${N}`;
|
|
41
|
+
export interface IVerificationKeys {
|
|
42
|
+
readonly methodSpecificId: TMethodSpecificId;
|
|
43
|
+
readonly didUrl: `did:cheqd:${CheqdNetwork}:${IVerificationKeys['methodSpecificId']}` extends string ? string : never;
|
|
44
|
+
readonly keyId: `${IVerificationKeys['didUrl']}#${TVerificationKey<TVerificationKeyPrefix, number>}`;
|
|
45
|
+
readonly publicKey: string;
|
|
46
|
+
}
|
|
47
|
+
export declare type TMethodSpecificId = string;
|
|
48
|
+
export interface DidStdFee {
|
|
49
|
+
readonly amount: readonly Coin[];
|
|
50
|
+
readonly gas: string;
|
|
51
|
+
payer?: string;
|
|
52
|
+
granter?: string;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"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,EAAE,iBAAiB,CAAA;IAC5C,QAAQ,CAAC,MAAM,EAAE,aAAa,YAAY,IAAI,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,GAAG,MAAM,GAAG,KAAK,CAAA;IACrH,QAAQ,CAAC,KAAK,EAAE,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,sBAAsB,EAAE,MAAM,CAAC,EAAE,CAAA;IACpG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC7B;AAED,oBAAY,iBAAiB,GAAG,MAAM,CAAA;AAEtC,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAA;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/build/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MethodSpecificIdAlgo = exports.VerificationMethods = exports.CheqdNetwork = void 0;
|
|
4
|
+
var CheqdNetwork;
|
|
5
|
+
(function (CheqdNetwork) {
|
|
6
|
+
CheqdNetwork["Mainnet"] = "mainnet";
|
|
7
|
+
CheqdNetwork["Testnet"] = "testnet";
|
|
8
|
+
})(CheqdNetwork = exports.CheqdNetwork || (exports.CheqdNetwork = {}));
|
|
9
|
+
var VerificationMethods;
|
|
10
|
+
(function (VerificationMethods) {
|
|
11
|
+
VerificationMethods["Base58"] = "Ed25519VerificationKey2020";
|
|
12
|
+
VerificationMethods["JWK"] = "JsonWebKey2020";
|
|
13
|
+
})(VerificationMethods = exports.VerificationMethods || (exports.VerificationMethods = {}));
|
|
14
|
+
var MethodSpecificIdAlgo;
|
|
15
|
+
(function (MethodSpecificIdAlgo) {
|
|
16
|
+
MethodSpecificIdAlgo["Base58"] = "base58btc";
|
|
17
|
+
MethodSpecificIdAlgo["Uuid"] = "uuid";
|
|
18
|
+
})(MethodSpecificIdAlgo = exports.MethodSpecificIdAlgo || (exports.MethodSpecificIdAlgo = {}));
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAIA,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;AACvB,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAYD,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC3B,4DAAqC,CAAA;IACrC,6CAAsB,CAAA;AAC1B,CAAC,EAHW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAG9B;AAED,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,4CAAoB,CAAA;IACpB,qCAAa,CAAA;AACjB,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B"}
|
package/build/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VerificationMethod } from "@cheqd/ts-proto/cheqd/v1/did";
|
|
2
|
+
import { IKeyValuePair, ISignInputs } from "./types";
|
|
3
|
+
export declare type TImportableEd25519Key = {
|
|
4
|
+
publicKeyHex: string;
|
|
5
|
+
privateKeyHex: string;
|
|
6
|
+
kid: string;
|
|
7
|
+
type: "Ed25519";
|
|
8
|
+
};
|
|
9
|
+
export declare function parseToKeyValuePair(object: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}): IKeyValuePair[];
|
|
12
|
+
export declare function createSignInputsFromImportableEd25519Key(key: TImportableEd25519Key, verificationMethod: VerificationMethod[]): ISignInputs;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAA;AAKzE,oBAAY,qBAAqB,GAAG;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,aAAa,EAAE,CAEnF;AAED,wBAAgB,wCAAwC,CAAC,GAAG,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,WAAW,CAgC1I"}
|
package/build/utils.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSignInputsFromImportableEd25519Key = exports.parseToKeyValuePair = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
const uint8arrays_1 = require("uint8arrays");
|
|
6
|
+
const basics_1 = require("multiformats/basics");
|
|
7
|
+
function parseToKeyValuePair(object) {
|
|
8
|
+
return Object.entries(object).map(([key, value]) => ({ key, value }));
|
|
9
|
+
}
|
|
10
|
+
exports.parseToKeyValuePair = parseToKeyValuePair;
|
|
11
|
+
function createSignInputsFromImportableEd25519Key(key, verificationMethod) {
|
|
12
|
+
if ((verificationMethod === null || verificationMethod === void 0 ? void 0 : verificationMethod.length) === 0)
|
|
13
|
+
throw new Error('No verification methods provided');
|
|
14
|
+
const publicKey = (0, uint8arrays_1.fromString)(key.publicKeyHex, 'hex');
|
|
15
|
+
for (const method of verificationMethod) {
|
|
16
|
+
switch (method === null || method === void 0 ? void 0 : method.type) {
|
|
17
|
+
case types_1.VerificationMethods.Base58:
|
|
18
|
+
const publicKeyMultibase = basics_1.bases['base58btc'].encode(publicKey);
|
|
19
|
+
if (method.publicKeyMultibase === publicKeyMultibase) {
|
|
20
|
+
return {
|
|
21
|
+
verificationMethodId: method.id,
|
|
22
|
+
privateKeyHex: key.privateKeyHex
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
case types_1.VerificationMethods.JWK:
|
|
26
|
+
const publicKeyJWK = parseToKeyValuePair({
|
|
27
|
+
crv: 'Ed25519',
|
|
28
|
+
kty: 'OKP',
|
|
29
|
+
x: (0, uint8arrays_1.toString)(publicKey, 'base64url')
|
|
30
|
+
});
|
|
31
|
+
if (method.publicKeyJwk === publicKeyJWK) {
|
|
32
|
+
return {
|
|
33
|
+
verificationMethodId: method.id,
|
|
34
|
+
privateKeyHex: key.privateKeyHex
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error('No verification method type provided');
|
|
40
|
+
}
|
|
41
|
+
exports.createSignInputsFromImportableEd25519Key = createSignInputsFromImportableEd25519Key;
|
|
42
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,mCAAyE;AACzE,6CAAkD;AAClD,gDAA2C;AAU3C,SAAgB,mBAAmB,CAAC,MAA8B;IAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AACzE,CAAC;AAFD,kDAEC;AAED,SAAgB,wCAAwC,CAAC,GAA0B,EAAE,kBAAwC;IACzH,IAAI,CAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,MAAM,MAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IAEzF,MAAM,SAAS,GAAG,IAAA,wBAAU,EAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;IAErD,KAAI,MAAM,MAAM,IAAI,kBAAkB,EAAE;QACpC,QAAQ,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,EAAE;YAClB,KAAK,2BAAmB,CAAC,MAAM;gBAC3B,MAAM,kBAAkB,GAAG,cAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;gBAC/D,IAAI,MAAM,CAAC,kBAAkB,KAAK,kBAAkB,EAAE;oBAClD,OAAO;wBACH,oBAAoB,EAAE,MAAM,CAAC,EAAE;wBAC/B,aAAa,EAAE,GAAG,CAAC,aAAa;qBACnC,CAAA;iBACJ;YAEL,KAAK,2BAAmB,CAAC,GAAG;gBACxB,MAAM,YAAY,GAAG,mBAAmB,CAAC;oBACrC,GAAG,EAAE,SAAS;oBACd,GAAG,EAAE,KAAK;oBACV,CAAC,EAAE,IAAA,sBAAQ,EAAE,SAAS,EAAE,WAAW,CAAE;iBACxC,CAAC,CAAA;gBACF,IAAI,MAAM,CAAC,YAAY,KAAK,YAAY,EAAE;oBACtC,OAAO;wBACH,oBAAoB,EAAE,MAAM,CAAC,EAAE;wBAC/B,aAAa,EAAE,GAAG,CAAC,aAAa;qBACnC,CAAA;iBACJ;SACR;KACJ;IAED,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;AAC3D,CAAC;AAhCD,4FAgCC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheqd/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "A TypeScript SDK built with CosmJS to interact with cheqd network ledger",
|
|
5
5
|
"licence": "Apache-2.0",
|
|
6
6
|
"author": "Cheqd Foundation Limited (https://github.com/cheqd)",
|
|
7
|
-
"
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"main": "build/index.js",
|
|
9
|
+
"types": "build/index.d.ts",
|
|
8
10
|
"scripts": {
|
|
9
11
|
"test": "jest --passWithNoTests",
|
|
10
12
|
"test:watch": "jest --passWithNoTests --watch",
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
"@semantic-release/npm": "^9.0.1",
|
|
32
34
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
33
35
|
"@types/jest": "^28.1.6",
|
|
36
|
+
"@types/long": "^4.0.2",
|
|
34
37
|
"@types/node": "^18.6.2",
|
|
35
38
|
"@types/uuid": "^8.3.4",
|
|
36
39
|
"conventional-changelog-conventionalcommits": "^5.0.0",
|
package/src/signer.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheqdExtensions } from './modules/_'
|
|
2
|
-
import { EncodeObject, isOfflineDirectSigner, OfflineSigner, encodePubkey, TxBodyEncodeObject, makeSignDoc
|
|
2
|
+
import { EncodeObject, isOfflineDirectSigner, OfflineSigner, encodePubkey, TxBodyEncodeObject, makeSignDoc } from "@cosmjs/proto-signing"
|
|
3
3
|
import { DeliverTxResponse, GasPrice, HttpEndpoint, QueryClient, SigningStargateClient, SigningStargateClientOptions, calculateFee, SignerData } from "@cosmjs/stargate"
|
|
4
4
|
import { Tendermint34Client } from "@cosmjs/tendermint-rpc"
|
|
5
5
|
import { createDefaultCheqdRegistry } from "./registry"
|
|
@@ -52,6 +52,8 @@ export function makeDidAuthInfoBytes(
|
|
|
52
52
|
payer: feePayer
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
//* There is a `Long` type incompatibility in the protobuf library that causes the following line to throw an error. No actual type mismatch is ever encountered.
|
|
56
|
+
// @ts-ignore
|
|
55
57
|
return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish()
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -3,7 +3,6 @@ import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"
|
|
|
3
3
|
import { DeliverTxResponse } from "@cosmjs/stargate"
|
|
4
4
|
import { fromString, toString } from 'uint8arrays'
|
|
5
5
|
import { DIDModule } from "../../src"
|
|
6
|
-
import { AbstractCheqdSDKModule } from "../../src/modules/_"
|
|
7
6
|
import { createDefaultCheqdRegistry } from "../../src/registry"
|
|
8
7
|
import { CheqdSigningStargateClient } from "../../src/signer"
|
|
9
8
|
import { DidStdFee, ISignInputs, MethodSpecificIdAlgo, VerificationMethods } from "../../src/types"
|
package/tsconfig.json
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
11
|
// "checkJs": true, /* Report errors in .js files. */
|
|
12
12
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
+
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
15
|
+
"sourceMap": true, /* Generates corresponding '.map' file. */
|
|
16
16
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
17
17
|
"outDir": "build", /* Redirect output structure to the directory. */
|
|
18
18
|
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// "removeComments": true, /* Do not emit comments to output. */
|
|
22
22
|
// "noEmit": true, /* Do not emit outputs. */
|
|
23
23
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
24
|
-
|
|
24
|
+
"downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
25
25
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
26
26
|
|
|
27
27
|
/* Strict Type-Checking Options */
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"types": [
|
|
51
51
|
"@types/node",
|
|
52
52
|
"@types/jest",
|
|
53
|
+
"@types/long"
|
|
53
54
|
], /* Type declaration files to be included in compilation. */
|
|
54
55
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
55
56
|
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|