@ckb-ccc/joy-id 0.0.5-alpha.10 → 0.0.5-alpha.12
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/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +11 -1
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +19 -40
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +14 -30
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +14 -30
- package/dist.commonjs/btc/index.d.ts +15 -22
- package/dist.commonjs/btc/index.js +73 -99
- package/dist.commonjs/ckb/index.d.ts +26 -33
- package/dist.commonjs/ckb/index.d.ts.map +1 -1
- package/dist.commonjs/ckb/index.js +171 -204
- package/dist.commonjs/common/index.d.ts +21 -34
- package/dist.commonjs/common/index.js +45 -50
- package/dist.commonjs/connectionsStorage/index.d.ts +14 -23
- package/dist.commonjs/connectionsStorage/index.js +25 -28
- package/dist.commonjs/evm/index.d.ts +15 -21
- package/dist.commonjs/evm/index.js +67 -89
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +19 -40
- package/dist.commonjs/signerFactory/index.d.ts +2 -6
- package/dist.commonjs/signerFactory/index.js +27 -38
- package/package.json +3 -3
- package/src/ckb/index.ts +16 -1
package/dist/ckb/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;IAqBrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ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Ud,iBAAiB;CAMhC"}
|
package/dist/ckb/index.js
CHANGED
|
@@ -126,11 +126,21 @@ export class CkbSigner extends ccc.Signer {
|
|
|
126
126
|
const tx = ccc.Transaction.from(txLike);
|
|
127
127
|
const { script } = await this.getAddressObj();
|
|
128
128
|
const config = this.getConfig();
|
|
129
|
+
const witnessIndexes = await Promise.all(tx.inputs.map(async (input, i) => {
|
|
130
|
+
await input.completeExtraInfos(this.client);
|
|
131
|
+
if (!input.cellOutput) {
|
|
132
|
+
throw Error("Unable to resolve inputs info");
|
|
133
|
+
}
|
|
134
|
+
if (!script.eq(input.cellOutput.lock)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
return i;
|
|
138
|
+
}));
|
|
129
139
|
const res = await createPopup(buildJoyIDURL({
|
|
130
140
|
...config,
|
|
131
141
|
tx: JSON.parse(tx.stringify()),
|
|
132
142
|
signerAddress: (await this.assertConnection()).address,
|
|
133
|
-
|
|
143
|
+
witnessIndexes: witnessIndexes.filter((i) => i !== undefined),
|
|
134
144
|
}, "popup", "/sign-ckb-raw-tx"), {
|
|
135
145
|
...config,
|
|
136
146
|
type: DappRequestType.SignCkbRawTx,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * as JoyIdA from "./advancedBarrel";
|
|
2
|
-
//# sourceMappingURL=advanced.d.ts.map
|
|
2
|
+
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __setModuleDefault =
|
|
26
|
-
(this && this.__setModuleDefault) ||
|
|
27
|
-
(Object.create
|
|
28
|
-
? function (o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}
|
|
31
|
-
: function (o, v) {
|
|
32
|
-
o["default"] = v;
|
|
33
|
-
});
|
|
34
|
-
var __importStar =
|
|
35
|
-
(this && this.__importStar) ||
|
|
36
|
-
function (mod) {
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
19
|
if (mod && mod.__esModule) return mod;
|
|
38
20
|
var result = {};
|
|
39
|
-
if (mod != null)
|
|
40
|
-
for (var k in mod)
|
|
41
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
42
|
-
__createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
43
22
|
__setModuleDefault(result, mod);
|
|
44
23
|
return result;
|
|
45
|
-
|
|
24
|
+
};
|
|
46
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
26
|
exports.JoyIdA = void 0;
|
|
48
27
|
exports.JoyIdA = __importStar(require("./advancedBarrel"));
|
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./common"), exports);
|
|
34
18
|
__exportStar(require("./connectionsStorage"), exports);
|
package/dist.commonjs/barrel.js
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}
|
|
21
|
-
: function (o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
});
|
|
25
|
-
var __exportStar =
|
|
26
|
-
(this && this.__exportStar) ||
|
|
27
|
-
function (m, exports) {
|
|
28
|
-
for (var p in m)
|
|
29
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
30
|
-
__createBinding(exports, m, p);
|
|
31
|
-
};
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
32
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
17
|
__exportStar(require("./btc"), exports);
|
|
34
18
|
__exportStar(require("./ckb"), exports);
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage";
|
|
3
3
|
export declare class BitcoinSigner extends ccc.SignerBtc {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
private getConfig;
|
|
20
|
-
getBtcAccount(): Promise<string>;
|
|
21
|
-
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
22
|
-
connect(): Promise<void>;
|
|
23
|
-
isConnected(): Promise<boolean>;
|
|
24
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
4
|
+
private readonly name;
|
|
5
|
+
private readonly icon;
|
|
6
|
+
private readonly addressType;
|
|
7
|
+
private readonly appUri;
|
|
8
|
+
private readonly connectionsRepo;
|
|
9
|
+
private connection?;
|
|
10
|
+
private assertConnection;
|
|
11
|
+
constructor(client: ccc.Client, name: string, icon: string, addressType?: "auto" | "p2wpkh" | "p2tr", appUri?: string, connectionsRepo?: ConnectionsRepo);
|
|
12
|
+
private getConfig;
|
|
13
|
+
getBtcAccount(): Promise<string>;
|
|
14
|
+
getBtcPublicKey(): Promise<ccc.Hex>;
|
|
15
|
+
connect(): Promise<void>;
|
|
16
|
+
isConnected(): Promise<boolean>;
|
|
17
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
25
18
|
}
|
|
26
|
-
//# sourceMappingURL=index.d.ts.map
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -6,106 +6,80 @@ const common_1 = require("@joyid/common");
|
|
|
6
6
|
const common_2 = require("../common");
|
|
7
7
|
const connectionsStorage_1 = require("../connectionsStorage");
|
|
8
8
|
class BitcoinSigner extends core_1.ccc.SignerBtc {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
assertConnection() {
|
|
10
|
+
if (!this.isConnected() || !this.connection) {
|
|
11
|
+
throw new Error("Not connected");
|
|
12
|
+
}
|
|
13
|
+
return this.connection;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
15
|
+
constructor(client, name, icon, addressType = "auto", appUri = "https://app.joy.id", connectionsRepo = new connectionsStorage_1.ConnectionsRepoLocalStorage()) {
|
|
16
|
+
super(client);
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.icon = icon;
|
|
19
|
+
this.addressType = addressType;
|
|
20
|
+
this.appUri = appUri;
|
|
21
|
+
this.connectionsRepo = connectionsRepo;
|
|
22
|
+
}
|
|
23
|
+
getConfig() {
|
|
24
|
+
return {
|
|
25
|
+
redirectURL: location.href,
|
|
26
|
+
joyidAppURL: this.appUri,
|
|
27
|
+
requestNetwork: `btc-${this.addressType}`,
|
|
28
|
+
name: this.name,
|
|
29
|
+
logo: this.icon,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async getBtcAccount() {
|
|
33
|
+
const { address } = this.assertConnection();
|
|
34
|
+
return address;
|
|
35
|
+
}
|
|
36
|
+
async getBtcPublicKey() {
|
|
37
|
+
const { publicKey } = this.assertConnection();
|
|
38
|
+
return publicKey;
|
|
39
|
+
}
|
|
40
|
+
async connect() {
|
|
41
|
+
const config = this.getConfig();
|
|
42
|
+
const res = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)(config, "popup", "/auth"), {
|
|
43
|
+
...config,
|
|
44
|
+
type: common_1.DappRequestType.Auth,
|
|
45
|
+
});
|
|
46
|
+
const { address, pubkey } = (() => {
|
|
47
|
+
if (this.addressType === "auto") {
|
|
48
|
+
return res.btcAddressType === "p2wpkh" ? res.nativeSegwit : res.taproot;
|
|
49
|
+
}
|
|
50
|
+
return res.btcAddressType === "p2wpkh" ? res.nativeSegwit : res.taproot;
|
|
51
|
+
})();
|
|
52
|
+
this.connection = {
|
|
53
|
+
address,
|
|
54
|
+
publicKey: core_1.ccc.hexFrom(pubkey),
|
|
55
|
+
keyType: res.keyType,
|
|
56
|
+
};
|
|
57
|
+
await Promise.all([
|
|
58
|
+
this.connectionsRepo.set({ uri: this.appUri, addressType: `btc-${res.btcAddressType}` }, this.connection),
|
|
59
|
+
this.connectionsRepo.set({ uri: this.appUri, addressType: "btc-auto" }, this.connection),
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
async isConnected() {
|
|
63
|
+
if (this.connection) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
this.connection = await this.connectionsRepo.get({
|
|
67
|
+
uri: this.appUri,
|
|
68
|
+
addressType: `btc-${this.addressType}`,
|
|
69
|
+
});
|
|
70
|
+
return this.connection !== undefined;
|
|
71
|
+
}
|
|
72
|
+
async signMessageRaw(message) {
|
|
73
|
+
const { address } = this.assertConnection();
|
|
74
|
+
const challenge = typeof message === "string" ? message : core_1.ccc.hexFrom(message).slice(2);
|
|
75
|
+
const config = this.getConfig();
|
|
76
|
+
const { signature } = await (0, common_2.createPopup)((0, common_1.buildJoyIDURL)({
|
|
77
|
+
...config,
|
|
78
|
+
challenge,
|
|
79
|
+
address,
|
|
80
|
+
signMessageType: "ecdsa",
|
|
81
|
+
}, "popup", "/sign-message"), { ...config, type: common_1.DappRequestType.SignMessage });
|
|
82
|
+
return signature;
|
|
81
83
|
}
|
|
82
|
-
this.connection = await this.connectionsRepo.get({
|
|
83
|
-
uri: this.appUri,
|
|
84
|
-
addressType: `btc-${this.addressType}`,
|
|
85
|
-
});
|
|
86
|
-
return this.connection !== undefined;
|
|
87
|
-
}
|
|
88
|
-
async signMessageRaw(message) {
|
|
89
|
-
const { address } = this.assertConnection();
|
|
90
|
-
const challenge =
|
|
91
|
-
typeof message === "string"
|
|
92
|
-
? message
|
|
93
|
-
: core_1.ccc.hexFrom(message).slice(2);
|
|
94
|
-
const config = this.getConfig();
|
|
95
|
-
const { signature } = await (0, common_2.createPopup)(
|
|
96
|
-
(0, common_1.buildJoyIDURL)(
|
|
97
|
-
{
|
|
98
|
-
...config,
|
|
99
|
-
challenge,
|
|
100
|
-
address,
|
|
101
|
-
signMessageType: "ecdsa",
|
|
102
|
-
},
|
|
103
|
-
"popup",
|
|
104
|
-
"/sign-message",
|
|
105
|
-
),
|
|
106
|
-
{ ...config, type: common_1.DappRequestType.SignMessage },
|
|
107
|
-
);
|
|
108
|
-
return signature;
|
|
109
|
-
}
|
|
110
84
|
}
|
|
111
85
|
exports.BitcoinSigner = BitcoinSigner;
|
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
import { ccc } from "@ckb-ccc/core";
|
|
2
2
|
import { ConnectionsRepo } from "../connectionsStorage";
|
|
3
3
|
export declare class CkbSigner extends ccc.Signer {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
getAddressObjs(): Promise<ccc.Address[]>;
|
|
30
|
-
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
31
|
-
private prepareTransactionForSubKey;
|
|
32
|
-
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
33
|
-
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
34
|
-
private saveConnection;
|
|
35
|
-
private restoreConnection;
|
|
4
|
+
private readonly name;
|
|
5
|
+
private readonly icon;
|
|
6
|
+
private readonly _appUri?;
|
|
7
|
+
private readonly _aggregatorUri?;
|
|
8
|
+
private readonly connectionsRepo;
|
|
9
|
+
get type(): ccc.SignerType;
|
|
10
|
+
get signType(): ccc.SignerSignType;
|
|
11
|
+
private connection?;
|
|
12
|
+
private assertConnection;
|
|
13
|
+
constructor(client: ccc.Client, name: string, icon: string, _appUri?: string | undefined, _aggregatorUri?: string | undefined, connectionsRepo?: ConnectionsRepo);
|
|
14
|
+
private getConfig;
|
|
15
|
+
private getAggregatorUri;
|
|
16
|
+
connect(): Promise<void>;
|
|
17
|
+
disconnect(): Promise<void>;
|
|
18
|
+
isConnected(): Promise<boolean>;
|
|
19
|
+
getInternalAddress(): Promise<string>;
|
|
20
|
+
getIdentity(): Promise<string>;
|
|
21
|
+
getAddressObj(): Promise<ccc.Address>;
|
|
22
|
+
getAddressObjs(): Promise<ccc.Address[]>;
|
|
23
|
+
prepareTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
24
|
+
private prepareTransactionForSubKey;
|
|
25
|
+
signOnlyTransaction(txLike: ccc.TransactionLike): Promise<ccc.Transaction>;
|
|
26
|
+
signMessageRaw(message: string | ccc.BytesLike): Promise<string>;
|
|
27
|
+
private saveConnection;
|
|
28
|
+
private restoreConnection;
|
|
36
29
|
}
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ckb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,SAAU,SAAQ,GAAG,CAAC,MAAM;IAqBrC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAxBlC,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,CAEzB;IAED,IAAI,QAAQ,IAAI,GAAG,CAAC,cAAc,CAEjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAa;YAElB,gBAAgB;gBAS5B,MAAM,EAAE,GAAG,CAAC,MAAM,EACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OA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