@hashgraph/hedera-wallet-connect 0.1.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/.github/ISSUE_TEMPLATE/hip_820.md +16 -0
- package/.github/dependabot.yml +17 -0
- package/.github/workflows/prettier.yml +28 -0
- package/.github/workflows/publish.yml +35 -0
- package/.github/workflows/test.yml +32 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc.json +5 -0
- package/.prettierignore +3 -0
- package/LICENSE +201 -21
- package/README.md +132 -107
- package/dist/browser-cjs-metafile.json +1 -0
- package/dist/browser-cjs.js +240 -0
- package/dist/browser-esm-metafile.json +1 -0
- package/dist/browser-esm.js +240 -0
- package/dist/node-cjs-metafile.json +1 -0
- package/dist/node-cjs.js +11391 -0
- package/dist/node-esm-metafile.json +1 -0
- package/dist/node-esm.js +11391 -0
- package/jest.config.ts +33 -0
- package/package.json +59 -31
- package/scripts/examples/build.mjs +54 -0
- package/scripts/examples/dev.mjs +54 -0
- package/scripts/lib/build.mjs +40 -0
- package/scripts/lib/context.mjs +71 -0
- package/scripts/lib/watch.mjs +28 -0
- package/typedoc.json +10 -0
- package/.editorconfig +0 -19
- package/.github/workflows/npm-publish.yml +0 -18
- package/lib/esm/Connector.js +0 -81
- package/lib/esm/Connector.js.map +0 -1
- package/lib/esm/DAppConnector.js +0 -118
- package/lib/esm/DAppConnector.js.map +0 -1
- package/lib/esm/ErrorHelper.js +0 -97
- package/lib/esm/ErrorHelper.js.map +0 -1
- package/lib/esm/Utils.js +0 -99
- package/lib/esm/Utils.js.map +0 -1
- package/lib/esm/WCSigner.js +0 -241
- package/lib/esm/WCSigner.js.map +0 -1
- package/lib/esm/WalletConnector.js +0 -203
- package/lib/esm/WalletConnector.js.map +0 -1
- package/lib/esm/index.js +0 -4
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/types/Connector.d.ts +0 -18
- package/lib/esm/types/Connector.d.ts.map +0 -1
- package/lib/esm/types/DAppConnector.d.ts +0 -27
- package/lib/esm/types/DAppConnector.d.ts.map +0 -1
- package/lib/esm/types/ErrorHelper.d.ts +0 -15
- package/lib/esm/types/ErrorHelper.d.ts.map +0 -1
- package/lib/esm/types/Utils.d.ts +0 -39
- package/lib/esm/types/Utils.d.ts.map +0 -1
- package/lib/esm/types/WCSigner.d.ts +0 -33
- package/lib/esm/types/WCSigner.d.ts.map +0 -1
- package/lib/esm/types/WalletConnector.d.ts +0 -21
- package/lib/esm/types/WalletConnector.d.ts.map +0 -1
- package/lib/esm/types/index.d.ts +0 -4
- package/lib/esm/types/index.d.ts.map +0 -1
@@ -1,203 +0,0 @@
|
|
1
|
-
import { Query, Transaction } from "@hashgraph/sdk";
|
2
|
-
import { formatJsonRpcError, formatJsonRpcResult } from "@json-rpc-tools/utils";
|
3
|
-
import { SignClient } from "@walletconnect/sign-client";
|
4
|
-
import { getSdkError } from "@walletconnect/utils";
|
5
|
-
import { Connector } from "./Connector.js";
|
6
|
-
import { getExtensionMethodsFromSession } from "./Utils.js";
|
7
|
-
export class WalletConnector extends Connector {
|
8
|
-
onProposalReceive;
|
9
|
-
constructor(metadata) {
|
10
|
-
super(metadata);
|
11
|
-
}
|
12
|
-
async init(onProposalReceive) {
|
13
|
-
this.onProposalReceive = onProposalReceive;
|
14
|
-
try {
|
15
|
-
this.isInitializing = true;
|
16
|
-
this.client = await SignClient.init({
|
17
|
-
relayUrl: "wss://relay.walletconnect.com",
|
18
|
-
projectId: "ce06497abf4102004138a10edd29c921",
|
19
|
-
metadata: this.dAppMetadata
|
20
|
-
});
|
21
|
-
this.subscribeToEvents();
|
22
|
-
await this.checkPersistedState();
|
23
|
-
}
|
24
|
-
finally {
|
25
|
-
this.isInitializing = false;
|
26
|
-
}
|
27
|
-
}
|
28
|
-
async pair(uri) {
|
29
|
-
if (!this.initialized) {
|
30
|
-
throw new Error("WC not initialized");
|
31
|
-
}
|
32
|
-
return await this.client.pair({ uri });
|
33
|
-
}
|
34
|
-
subscribeToEvents() {
|
35
|
-
if (!this.client) {
|
36
|
-
throw new Error("WC is not initialized");
|
37
|
-
}
|
38
|
-
this.client.on("session_proposal", this.onSessionProposal.bind(this));
|
39
|
-
this.client.on("session_request", this.onSessionRequest.bind(this));
|
40
|
-
this.client.on("session_delete", this.destroySession.bind(this));
|
41
|
-
this.client.on("session_expire", this.destroySession.bind(this));
|
42
|
-
}
|
43
|
-
async destroySession(event) {
|
44
|
-
this.session = null;
|
45
|
-
}
|
46
|
-
async onSessionRequest(requestEvent) {
|
47
|
-
const { id, topic, params } = requestEvent;
|
48
|
-
const { request, chainId } = params;
|
49
|
-
const accountId = request.params.accountId;
|
50
|
-
const signer = this.signers.find(s => s.getAccountId().toString() === accountId);
|
51
|
-
if (!signer) {
|
52
|
-
const formattedResult = formatJsonRpcError(id, "Signer is not available anymore");
|
53
|
-
await this.client.respond({
|
54
|
-
topic,
|
55
|
-
response: formattedResult
|
56
|
-
});
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
try {
|
60
|
-
let formattedResult;
|
61
|
-
switch (request.method) {
|
62
|
-
case "getLedgerId": {
|
63
|
-
const result = await signer.getLedgerId();
|
64
|
-
formattedResult = formatJsonRpcResult(id, result);
|
65
|
-
break;
|
66
|
-
}
|
67
|
-
case "getAccountId": {
|
68
|
-
const result = await signer.getAccountId();
|
69
|
-
formattedResult = formatJsonRpcResult(id, result);
|
70
|
-
break;
|
71
|
-
}
|
72
|
-
case "getAccountKey": {
|
73
|
-
const result = await signer.getAccountKey();
|
74
|
-
formattedResult = formatJsonRpcResult(id, result);
|
75
|
-
break;
|
76
|
-
}
|
77
|
-
case "getNetwork": {
|
78
|
-
const result = await signer.getNetwork();
|
79
|
-
formattedResult = formatJsonRpcResult(id, result);
|
80
|
-
break;
|
81
|
-
}
|
82
|
-
case "getMirrorNetwork": {
|
83
|
-
const result = await signer.getMirrorNetwork();
|
84
|
-
formattedResult = formatJsonRpcResult(id, result);
|
85
|
-
break;
|
86
|
-
}
|
87
|
-
case "sign": {
|
88
|
-
const signatures = await signer.sign(request.params.messages, request.params.signOptions);
|
89
|
-
formattedResult = formatJsonRpcResult(id, signatures);
|
90
|
-
break;
|
91
|
-
}
|
92
|
-
case "getAccountBalance": {
|
93
|
-
const result = await signer.getAccountBalance();
|
94
|
-
formattedResult = formatJsonRpcResult(id, result);
|
95
|
-
break;
|
96
|
-
}
|
97
|
-
case "getAccountInfo": {
|
98
|
-
const result = await signer.getAccountInfo();
|
99
|
-
formattedResult = formatJsonRpcResult(id, result);
|
100
|
-
break;
|
101
|
-
}
|
102
|
-
case "getAccountRecords": {
|
103
|
-
const result = await signer.getAccountRecords();
|
104
|
-
formattedResult = formatJsonRpcResult(id, result);
|
105
|
-
break;
|
106
|
-
}
|
107
|
-
case "signTransaction": {
|
108
|
-
const transaction = await Transaction.fromBytes(Buffer.from(request.params.executable, "base64"));
|
109
|
-
const signedTransaction = await signer.signTransaction(transaction);
|
110
|
-
const encodedTransaction = Buffer.from(signedTransaction.toBytes()).toString("base64");
|
111
|
-
formattedResult = formatJsonRpcResult(id, encodedTransaction);
|
112
|
-
break;
|
113
|
-
}
|
114
|
-
case "checkTransaction": {
|
115
|
-
const transaction = await Transaction.fromBytes(Buffer.from(request.params.executable, "base64"));
|
116
|
-
const checkedTransaction = await signer.checkTransaction(transaction);
|
117
|
-
const encodedTransaction = Buffer.from(checkedTransaction.toBytes()).toString("base64");
|
118
|
-
formattedResult = formatJsonRpcResult(id, encodedTransaction);
|
119
|
-
break;
|
120
|
-
}
|
121
|
-
case "populateTransaction": {
|
122
|
-
const transaction = await Transaction.fromBytes(Buffer.from(request.params.executable, "base64"));
|
123
|
-
const populatedTransaction = await signer.populateTransaction(transaction);
|
124
|
-
const encodedTransaction = Buffer.from(populatedTransaction.toBytes()).toString("base64");
|
125
|
-
formattedResult = formatJsonRpcResult(id, encodedTransaction);
|
126
|
-
break;
|
127
|
-
}
|
128
|
-
case "call": {
|
129
|
-
const encodedExecutable = request.params.executable;
|
130
|
-
const isTransaction = request.params.isTransaction;
|
131
|
-
const bytes = Buffer.from(encodedExecutable, "base64");
|
132
|
-
let result;
|
133
|
-
if (isTransaction) {
|
134
|
-
const transaction = Transaction.fromBytes(bytes);
|
135
|
-
result = (await signer.call(transaction)).toJSON();
|
136
|
-
}
|
137
|
-
else {
|
138
|
-
const query = Query.fromBytes(bytes);
|
139
|
-
const queryResult = await signer.call(query);
|
140
|
-
result = Buffer.from(queryResult.toBytes()).toString("base64");
|
141
|
-
}
|
142
|
-
formattedResult = formatJsonRpcResult(id, result);
|
143
|
-
break;
|
144
|
-
}
|
145
|
-
default: {
|
146
|
-
const extensionMethods = getExtensionMethodsFromSession(this.session);
|
147
|
-
if (extensionMethods.includes(request.method)) {
|
148
|
-
const result = await signer[request.method](...request.params.args);
|
149
|
-
formattedResult = formatJsonRpcResult(id, result);
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
throw new Error(getSdkError("INVALID_METHOD").message);
|
153
|
-
}
|
154
|
-
}
|
155
|
-
}
|
156
|
-
await this.client.respond({
|
157
|
-
topic,
|
158
|
-
response: formattedResult
|
159
|
-
});
|
160
|
-
}
|
161
|
-
catch (e) {
|
162
|
-
const formattedResult = formatJsonRpcError(id, e);
|
163
|
-
await this.client.respond({
|
164
|
-
topic,
|
165
|
-
response: formattedResult
|
166
|
-
});
|
167
|
-
}
|
168
|
-
}
|
169
|
-
async onSessionProposal(proposal) {
|
170
|
-
await this.onProposalReceive(proposal);
|
171
|
-
}
|
172
|
-
async approveSessionProposal(data, signers) {
|
173
|
-
const accountConfigs = Object.values(data.namespaces).flatMap(ns => ns.accounts.map(acc => {
|
174
|
-
const [network, chainId, accountId] = acc.split(":");
|
175
|
-
return { network, chainId, accountId };
|
176
|
-
}));
|
177
|
-
const signerAccounts = signers.map(signer => signer.getAccountId().toString());
|
178
|
-
const hasValidSigners = accountConfigs.every(config => signerAccounts.includes(config.accountId));
|
179
|
-
if (!hasValidSigners) {
|
180
|
-
throw new Error("Required signers are missing");
|
181
|
-
}
|
182
|
-
this.signers = signers;
|
183
|
-
const { acknowledged } = await this.client.approve(data);
|
184
|
-
this.session = await acknowledged();
|
185
|
-
return this.session;
|
186
|
-
}
|
187
|
-
async rejectSessionProposal(data) {
|
188
|
-
return this.client.reject(data);
|
189
|
-
}
|
190
|
-
async sendEvent(name, data) {
|
191
|
-
if (!this.session) {
|
192
|
-
throw new Error("No connection session exist!");
|
193
|
-
}
|
194
|
-
const chainId = Object.values(this.session.namespaces)
|
195
|
-
.flatMap(ns => ns.accounts.map(acc => acc.split(":").slice(0, 2).join(":")))[0];
|
196
|
-
const allowedEvents = Object.values(this.session.namespaces)
|
197
|
-
.flatMap(ns => ns.events);
|
198
|
-
if (allowedEvents.includes(name)) {
|
199
|
-
await this.client.emit({ topic: this.session.topic, chainId, event: { name, data } });
|
200
|
-
}
|
201
|
-
}
|
202
|
-
}
|
203
|
-
//# sourceMappingURL=WalletConnector.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"WalletConnector.js","sourceRoot":"","sources":["../../src/WalletConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAA2B,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAI5D,MAAM,OAAO,eAAgB,SAAQ,SAAS;IACrC,iBAAiB,CAAmB;IAE3C,YAAY,QAAmC;QAC7C,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,iBAAmC;QACnD,IAAI,CAAC,i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AI,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,EAAC,CAAC,CAAC;SACnF;IACH,CAAC;CACF","sourcesContent":["import {Query, Signer, SignerSignature, Transaction} from \"@hashgraph/sdk\";\nimport {formatJsonRpcError, formatJsonRpcResult} from \"@json-rpc-tools/utils\";\nimport {SignClient} from \"@walletconnect/sign-client\";\nimport {EngineTypes, PairingTypes, SessionTypes, SignClientTypes} from \"@walletconnect/types\";\nimport {getSdkError} from \"@walletconnect/utils\";\nimport {Connector} from \"./Connector.js\";\nimport ApproveParams = EngineTypes.ApproveParams;\nimport RejectParams = EngineTypes.RejectParams;\nimport { getExtensionMethodsFromSession } from \"./Utils.js\";\n\ntype ProposalCallback = (proposal: SignClientTypes.EventArguments[\"session_proposal\"]) => Promise<void>;\n\nexport class WalletConnector extends Connector {\n public onProposalReceive: ProposalCallback;\n\n constructor(metadata?: SignClientTypes.Metadata) {\n super(metadata);\n }\n\n public async init(onProposalReceive: ProposalCallback) {\n this.onProposalReceive = onProposalReceive;\n try {\n this.isInitializing = true;\n this.client = await SignClient.init({\n relayUrl: \"wss://relay.walletconnect.com\",\n projectId: \"ce06497abf4102004138a10edd29c921\",\n metadata: this.dAppMetadata\n });\n this.subscribeToEvents();\n await this.checkPersistedState();\n } finally {\n this.isInitializing = false;\n }\n }\n\n public async pair(uri: string): Promise<PairingTypes.Struct> {\n if (!this.initialized) {\n throw new Error(\"WC not initialized\");\n }\n\n return await this.client.pair({uri});\n }\n\n private subscribeToEvents() {\n if (!this.client) {\n throw new Error(\"WC is not initialized\");\n }\n this.client.on(\"session_proposal\", this.onSessionProposal.bind(this));\n this.client.on(\"session_request\", this.onSessionRequest.bind(this));\n this.client.on(\"session_delete\", this.destroySession.bind(this));\n this.client.on(\"session_expire\", this.destroySession.bind(this));\n }\n\n private async destroySession(event: SignClientTypes.EventArguments[\"session_expire\"] | SignClientTypes.EventArguments[\"session_delete\"]) {\n this.session = null;\n }\n\n private async onSessionRequest(requestEvent: SignClientTypes.EventArguments[\"session_request\"]) {\n const {id, topic, params} = requestEvent;\n const {request, chainId} = params;\n const accountId = request.params.accountId;\n const signer = this.signers.find(s => s.getAccountId().toString() === accountId);\n\n if (!signer) {\n const formattedResult = formatJsonRpcError(id, \"Signer is not available anymore\");\n await this.client.respond({\n topic,\n response: formattedResult\n });\n return;\n }\n\n try {\n let formattedResult;\n switch (request.method) {\n case \"getLedgerId\": {\n const result = await signer.getLedgerId();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"getAccountId\": {\n const result = await signer.getAccountId();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"getAccountKey\": {\n const result = await signer.getAccountKey();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"getNetwork\": {\n const result = await signer.getNetwork();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"getMirrorNetwork\": {\n const result = await signer.getMirrorNetwork();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"sign\": {\n const signatures: SignerSignature[] = await signer.sign(request.params.messages, request.params.signOptions)\n formattedResult = formatJsonRpcResult(id, signatures);\n break;\n }\n case \"getAccountBalance\": {\n const result = await signer.getAccountBalance();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"getAccountInfo\": {\n const result = await signer.getAccountInfo();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"getAccountRecords\": {\n const result = await signer.getAccountRecords();\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n case \"signTransaction\": {\n const transaction = await Transaction.fromBytes(Buffer.from(request.params.executable, \"base64\"))\n const signedTransaction = await signer.signTransaction(transaction);\n const encodedTransaction = Buffer.from(signedTransaction.toBytes()).toString(\"base64\");\n formattedResult = formatJsonRpcResult(id, encodedTransaction);\n break;\n }\n case \"checkTransaction\": {\n const transaction = await Transaction.fromBytes(Buffer.from(request.params.executable, \"base64\"))\n const checkedTransaction = await signer.checkTransaction(transaction);\n const encodedTransaction = Buffer.from(checkedTransaction.toBytes()).toString(\"base64\");\n formattedResult = formatJsonRpcResult(id, encodedTransaction);\n break;\n }\n case \"populateTransaction\": {\n const transaction = await Transaction.fromBytes(Buffer.from(request.params.executable, \"base64\"))\n const populatedTransaction = await signer.populateTransaction(transaction);\n const encodedTransaction = Buffer.from(populatedTransaction.toBytes()).toString(\"base64\");\n formattedResult = formatJsonRpcResult(id, encodedTransaction);\n break;\n }\n case \"call\": {\n const encodedExecutable = request.params.executable;\n const isTransaction = request.params.isTransaction;\n const bytes = Buffer.from(encodedExecutable, \"base64\");\n let result;\n if (isTransaction) {\n const transaction = Transaction.fromBytes(bytes);\n result = (await signer.call(transaction)).toJSON();\n } else {\n const query = Query.fromBytes(bytes);\n const queryResult: any = await signer.call(query);\n result = Buffer.from(queryResult.toBytes()).toString(\"base64\");\n }\n formattedResult = formatJsonRpcResult(id, result);\n break;\n }\n default: {\n const extensionMethods = getExtensionMethodsFromSession(this.session);\n if (extensionMethods.includes(request.method)) {\n const result = await signer[request.method](...request.params.args)\n formattedResult = formatJsonRpcResult(id, result);\n } else {\n throw new Error(getSdkError(\"INVALID_METHOD\").message);\n }\n }\n }\n await this.client.respond({\n topic,\n response: formattedResult\n });\n } catch (e: any) {\n const formattedResult = formatJsonRpcError(id, e);\n await this.client.respond({\n topic,\n response: formattedResult\n });\n }\n }\n\n private async onSessionProposal(proposal: SignClientTypes.EventArguments[\"session_proposal\"]): Promise<void> {\n await this.onProposalReceive(proposal)\n }\n\n public async approveSessionProposal<T extends Signer>(data: ApproveParams, signers: T[]): Promise<SessionTypes.Struct> {\n const accountConfigs = Object.values(data.namespaces).flatMap(ns => ns.accounts.map(acc => {\n const [network, chainId, accountId] = acc.split(\":\");\n return {network, chainId, accountId};\n }));\n const signerAccounts = signers.map(signer => signer.getAccountId().toString());\n const hasValidSigners = accountConfigs.every(config => signerAccounts.includes(config.accountId));\n\n if (!hasValidSigners) {\n throw new Error(\"Required signers are missing\");\n }\n\n this.signers = signers;\n const {acknowledged} = await this.client.approve(data);\n this.session = await acknowledged();\n return this.session;\n }\n\n public async rejectSessionProposal(data: RejectParams): Promise<void> {\n return this.client.reject(data);\n }\n\n public async sendEvent(name: string, data: any): Promise<void> {\n if (!this.session) {\n throw new Error(\"No connection session exist!\");\n }\n\n const chainId = Object.values(this.session.namespaces)\n .flatMap(ns => ns.accounts.map(acc => acc.split(\":\").slice(0,2).join(\":\")))[0];\n const allowedEvents = Object.values(this.session.namespaces)\n .flatMap(ns => ns.events);\n if (allowedEvents.includes(name)) {\n await this.client.emit({topic: this.session.topic, chainId, event: {name, data}});\n }\n }\n}\n"]}
|
package/lib/esm/index.js
DELETED
package/lib/esm/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAA","sourcesContent":["export * from \"./DAppConnector.js\";\nexport * from \"./WalletConnector.js\";\nexport * from \"./Utils.js\"\n"]}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import SignClient from "@walletconnect/sign-client";
|
2
|
-
import { Signer } from "@hashgraph/sdk";
|
3
|
-
import { SessionTypes, SignClientTypes } from "@walletconnect/types";
|
4
|
-
declare type Client = SignClient.default;
|
5
|
-
export declare class Connector {
|
6
|
-
protected readonly dAppMetadata: SignClientTypes.Metadata;
|
7
|
-
protected isInitializing: boolean;
|
8
|
-
protected client: Client | null;
|
9
|
-
protected session: SessionTypes.Struct | null;
|
10
|
-
protected signers: Signer[];
|
11
|
-
protected constructor(metadata?: SignClientTypes.Metadata);
|
12
|
-
checkPersistedState(): Promise<SessionTypes.Struct>;
|
13
|
-
disconnect(): Promise<void>;
|
14
|
-
private reset;
|
15
|
-
get initialized(): boolean;
|
16
|
-
}
|
17
|
-
export {};
|
18
|
-
//# sourceMappingURL=Connector.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/Connector.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAGnE,OAAO,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC;AAEzC,qBAAa,SAAS;IACpB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC,QAAQ,CAAC;IAC1D,SAAS,CAAC,cAAc,EAAE,OAAO,CAAS;IAC1C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IACvC,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM,GAAG,IAAI,CAAQ;IACrD,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,CAAM;IAEjC,SAAS,aAAa,QAAQ,CAAC,EAAE,eAAe,CAAC,QAAQ;IAInD,mBAAmB;IAqDnB,UAAU;IAgBhB,OAAO,CAAC,KAAK;IAKb,IAAI,WAAW,IAAI,OAAO,CAEzB;CACF"}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { LedgerId } from "@hashgraph/sdk";
|
2
|
-
import { SessionTypes, SignClientTypes } from "@walletconnect/types";
|
3
|
-
import { Subject } from "rxjs";
|
4
|
-
import { Connector } from "./Connector.js";
|
5
|
-
type WalletEvent = {
|
6
|
-
name: string;
|
7
|
-
data: any;
|
8
|
-
};
|
9
|
-
export type DAppMetadata = SignClientTypes.Metadata;
|
10
|
-
export declare class DAppConnector extends Connector {
|
11
|
-
private allowedEvents;
|
12
|
-
private extensionMethods;
|
13
|
-
static instance: DAppConnector;
|
14
|
-
$events: Subject<WalletEvent>;
|
15
|
-
constructor(metadata?: DAppMetadata);
|
16
|
-
init(events?: string[], methods?: string[]): Promise<void>;
|
17
|
-
private subscribeToEvents;
|
18
|
-
connect(ledgerId?: LedgerId, activeTopic?: string): Promise<void>;
|
19
|
-
prepareConnectURI(ledgerId?: LedgerId, activeTopic?: string): Promise<{
|
20
|
-
uri?: string;
|
21
|
-
approval: () => Promise<SessionTypes.Struct>;
|
22
|
-
}>;
|
23
|
-
onSessionConnected(session: SessionTypes.Struct): Promise<void>;
|
24
|
-
getSigners(): Signer[];
|
25
|
-
}
|
26
|
-
export {};
|
27
|
-
//# sourceMappingURL=DAppConnector.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"DAppConnector.d.ts","sourceRoot":"","sources":["../../../src/DAppConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AASzC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC;AAEpD,qBAAa,aAAc,SAAQ,SAAS;IAC1C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,gBAAgB,CAAgB;IACxC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAA8B;gBAEtD,QAAQ,CAAC,EAAE,YAAY;IAK7B,IAAI,CAAC,MAAM,GAAE,MAAM,EAAO,EAAE,OAAO,GAAE,MAAM,EAAO;IAoBxD,OAAO,CAAC,iBAAiB;IAkBnB,OAAO,CAAC,QAAQ,GAAE,QAA2B,EAAE,WAAW,CAAC,EAAE,MAAM;IAwCnE,iBAAiB,CAAC,QAAQ,GAAE,QAA2B,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5F,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;KAC9C,CAAC;IAqBI,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,MAAM;IAYrD,UAAU;CAGX"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
type HandlerFunction = (error: Error, ctx: any) => Promise<boolean> | boolean;
|
2
|
-
type CatchOptions = {
|
3
|
-
retry?: boolean;
|
4
|
-
retryDelay?: number;
|
5
|
-
};
|
6
|
-
export declare class HWCError extends Error {
|
7
|
-
readonly code: number;
|
8
|
-
readonly description: string;
|
9
|
-
readonly error: Error | {};
|
10
|
-
constructor(code: number, description: string, error: Error | {});
|
11
|
-
}
|
12
|
-
export declare const Catch: (errorType: any, handler: HandlerFunction, options?: CatchOptions) => any;
|
13
|
-
export declare const CatchAll: (handler: HandlerFunction, options?: CatchOptions) => any;
|
14
|
-
export {};
|
15
|
-
//# sourceMappingURL=ErrorHelper.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ErrorHelper.d.ts","sourceRoot":"","sources":["../../../src/ErrorHelper.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAC9E,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,qBAAa,QAAS,SAAQ,KAAK;aAEf,IAAI,EAAE,MAAM;aACZ,WAAW,EAAE,MAAM;aACnB,KAAK,EAAE,KAAK,GAAG,EAAE;gBAFjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,GAAG,EAAE;CAIpC;AAMD,eAAO,MAAM,KAAK,cAAe,GAAG,WAAW,eAAe,YAAY,YAAY,KAAG,GA0FxF,CAAC;AAEF,eAAO,MAAM,QAAQ,YAAa,eAAe,YAAY,YAAY,KAAG,GAAqC,CAAC"}
|
package/lib/esm/types/Utils.d.ts
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
import { LedgerId, PublicKey } from "@hashgraph/sdk";
|
2
|
-
import { ProposalTypes, SessionTypes } from "@walletconnect/types";
|
3
|
-
export declare enum METHODS {
|
4
|
-
SIGN_TRANSACTION = "signTransaction",
|
5
|
-
CALL = "call",
|
6
|
-
GET_ACCOUNT_BALANCE = "getAccountBalance",
|
7
|
-
GET_ACCOUNT_INFO = "getAccountInfo",
|
8
|
-
GET_LEDGER_ID = "getLedgerId",
|
9
|
-
GET_ACCOUNT_ID = "getAccountId",
|
10
|
-
GET_ACCOUNT_KEY = "getAccountKey",
|
11
|
-
GET_NETWORK = "getNetwork",
|
12
|
-
GET_MIRROR_NETWORK = "getMirrorNetwork",
|
13
|
-
SIGN = "sign",
|
14
|
-
GET_ACCOUNT_RECORDS = "getAccountRecords",
|
15
|
-
CHECK_TRANSACTION = "checkTransaction",
|
16
|
-
POPULATE_TRANSACTION = "populateTransaction"
|
17
|
-
}
|
18
|
-
export declare enum EVENTS {
|
19
|
-
ACCOUNTS_CHANGED = "accountsChanged"
|
20
|
-
}
|
21
|
-
export declare const getChainByLedgerId: (ledgerId: LedgerId) => string;
|
22
|
-
export declare const getLedgerIdByChainId: (chainId: string) => string;
|
23
|
-
export declare const getRequiredNamespaces: (ledgerId: LedgerId) => ProposalTypes.RequiredNamespaces;
|
24
|
-
export declare const getLedgerIDsFromSession: (session: SessionTypes.Struct) => LedgerId[];
|
25
|
-
export declare const getAccountLedgerPairsFromSession: (session: SessionTypes.Struct) => {
|
26
|
-
network: LedgerId;
|
27
|
-
account: string;
|
28
|
-
}[];
|
29
|
-
export declare const getExtensionMethodsFromSession: (session: SessionTypes.Struct) => string[];
|
30
|
-
type Encodable = {
|
31
|
-
toBytes(): Uint8Array;
|
32
|
-
};
|
33
|
-
export declare const isEncodable: (obj: any) => obj is Encodable;
|
34
|
-
export declare const isTransaction: (obj: any) => obj is Transaction;
|
35
|
-
export declare const evmAddressFromObject: (data: any) => string | null;
|
36
|
-
export declare const publicKeyFromObject: (data: any) => PublicKey | null;
|
37
|
-
export declare const convertToSignerSignature: (data: any) => SignerSignature;
|
38
|
-
export {};
|
39
|
-
//# sourceMappingURL=Utils.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/Utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,QAAQ,EAAE,SAAS,EAA+B,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAQjE,oBAAY,OAAO;IACjB,gBAAgB,oBAAoB;IACpC,IAAI,SAAS;IACb,mBAAmB,sBAAsB;IACzC,gBAAgB,mBAAmB;IACnC,aAAa,gBAAgB;IAC7B,cAAc,iBAAiB;IAC/B,eAAe,kBAAkB;IACjC,WAAW,eAAe;IAC1B,kBAAkB,qBAAqB;IACvC,IAAI,SAAS;IACb,mBAAmB,sBAAsB;IACzC,iBAAiB,qBAAqB;IACtC,oBAAoB,wBAAwB;CAC7C;AAED,oBAAY,MAAM;IAChB,gBAAgB,oBAAoB;CACrC;AAED,eAAO,MAAM,kBAAkB,0BAAyB,MAEvD,CAAA;AAED,eAAO,MAAM,oBAAoB,YAAa,MAAM,KAAG,MAGtD,CAAC;AAEF,eAAO,MAAM,qBAAqB,0BAAyB,cAAc,kBAQxE,CAAC;AAEF,eAAO,MAAM,uBAAuB,YAAa,aAAa,MAAM,KAAG,QAAQ,EAM9E,CAAC;AACF,eAAO,MAAM,gCAAgC,YAAa,aAAa,MAAM,KAAG;IAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,EAMnH,CAAC;AAEF,eAAO,MAAM,8BAA8B,YAAa,aAAa,MAAM,KAAG,MAAM,EAInF,CAAA;AAED,KAAK,SAAS,GAAG;IACf,OAAO,IAAI,UAAU,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,GAAG,qBAGnC,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,GAAG,uBAOrC,CAAC;AAEF,eAAO,MAAM,oBAAoB,iBAAW,MAAM,GAAG,IAMpD,CAAA;AAED,eAAO,MAAM,mBAAmB,iBAAW,SAAS,GAAG,IAMtD,CAAA;AAED,eAAO,MAAM,wBAAwB,gCAOpC,CAAA"}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { Signer } from '@hashgraph/sdk';
|
2
|
-
import { AccountBalance, AccountId, AccountInfo, Executable, Key, LedgerId, SignerSignature, Transaction, TransactionRecord } from "@hashgraph/sdk";
|
3
|
-
import { ISignClient } from "@walletconnect/types";
|
4
|
-
/**
|
5
|
-
* Implements Hedera Signer interface.
|
6
|
-
* https://hips.hedera.com/hip/hip-338
|
7
|
-
*/
|
8
|
-
export declare class WCSigner implements Signer {
|
9
|
-
private readonly accountId;
|
10
|
-
private readonly client;
|
11
|
-
private readonly topic;
|
12
|
-
private readonly ledgerId;
|
13
|
-
private extensionMethods;
|
14
|
-
constructor(accountId: AccountId, client: ISignClient, topic: string, ledgerId?: LedgerId, extensionMethods?: string[]);
|
15
|
-
private wrappedRequest;
|
16
|
-
getAccountId(): AccountId;
|
17
|
-
getAccountKey(): Promise<Key>;
|
18
|
-
getLedgerId(): LedgerId;
|
19
|
-
getNetwork(): Promise<{
|
20
|
-
[key: string]: (string | AccountId);
|
21
|
-
}>;
|
22
|
-
getMirrorNetwork(): Promise<string[]>;
|
23
|
-
sign(messages: Uint8Array[], signOptions?: Record<string, any>): Promise<SignerSignature[]>;
|
24
|
-
private extensionMethodCall;
|
25
|
-
getAccountBalance(): Promise<AccountBalance>;
|
26
|
-
getAccountInfo(): Promise<AccountInfo>;
|
27
|
-
getAccountRecords(): Promise<TransactionRecord[]>;
|
28
|
-
signTransaction<T extends Transaction>(transaction: T): Promise<T>;
|
29
|
-
checkTransaction<T extends Transaction>(transaction: T): Promise<T>;
|
30
|
-
populateTransaction<T extends Transaction>(transaction: T): Promise<T>;
|
31
|
-
call<RequestT, ResponseT, OutputT>(request: Executable<RequestT, ResponseT, OutputT>): Promise<OutputT>;
|
32
|
-
}
|
33
|
-
//# sourceMappingURL=WCSigner.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"WCSigner.d.ts","sourceRoot":"","sources":["../../../src/WCSigner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,SAAS,EACT,WAAW,EACX,UAAU,EACV,GAAG,EACH,QAAQ,EACR,eAAe,EACf,WAAW,EAEX,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAyCjD;;;GAGG;AACH,qBACa,QAAS,YAAW,MAAM;IAEjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,gBAAgB;gBAJP,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,QAA2B,EAC9C,gBAAgB,GAAE,MAAM,EAAO;IAS3C,OAAO,CAAC,cAAc;IAiBtB,YAAY,IAAI,SAAS;IAInB,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC;IAanC,WAAW,IAAI,QAAQ;IAIjB,UAAU,IAAI,OAAO,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;KAAC,CAAC;IAa5D,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAarC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;YAiBnF,mBAAmB;IAejC,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAa5C,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAatC,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAa3C,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAgBlE,gBAAgB,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAiCnE,mBAAmB,CAAC,CAAC,SAAS,WAAW,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAYtE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAgC9G"}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { Signer } from "@hashgraph/sdk";
|
2
|
-
import { EngineTypes, PairingTypes, SessionTypes, SignClientTypes } from "@walletconnect/types";
|
3
|
-
import { Connector } from "./Connector.js";
|
4
|
-
import ApproveParams = EngineTypes.ApproveParams;
|
5
|
-
import RejectParams = EngineTypes.RejectParams;
|
6
|
-
type ProposalCallback = (proposal: SignClientTypes.EventArguments["session_proposal"]) => Promise<void>;
|
7
|
-
export declare class WalletConnector extends Connector {
|
8
|
-
onProposalReceive: ProposalCallback;
|
9
|
-
constructor(metadata?: SignClientTypes.Metadata);
|
10
|
-
init(onProposalReceive: ProposalCallback): Promise<void>;
|
11
|
-
pair(uri: string): Promise<PairingTypes.Struct>;
|
12
|
-
private subscribeToEvents;
|
13
|
-
private destroySession;
|
14
|
-
private onSessionRequest;
|
15
|
-
private onSessionProposal;
|
16
|
-
approveSessionProposal<T extends Signer>(data: ApproveParams, signers: T[]): Promise<SessionTypes.Struct>;
|
17
|
-
rejectSessionProposal(data: RejectParams): Promise<void>;
|
18
|
-
sendEvent(name: string, data: any): Promise<void>;
|
19
|
-
}
|
20
|
-
export {};
|
21
|
-
//# sourceMappingURL=WalletConnector.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"WalletConnector.d.ts","sourceRoot":"","sources":["../../../src/WalletConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAA+B,MAAM,gBAAgB,CAAC;AAG3E,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAE9F,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC;AACjD,OAAO,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC;AAG/C,KAAK,gBAAgB,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,kBAAkB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAExG,qBAAa,eAAgB,SAAQ,SAAS;IACrC,iBAAiB,EAAE,gBAAgB,CAAC;gBAE/B,QAAQ,CAAC,EAAE,eAAe,CAAC,QAAQ;IAIlC,IAAI,CAAC,iBAAiB,EAAE,gBAAgB;IAgBxC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC;IAQ5D,OAAO,CAAC,iBAAiB;YAUX,cAAc;YAId,gBAAgB;YA2HhB,iBAAiB;IAIlB,sBA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