@hashgraph/hedera-wallet-connect 2.0.1-canary.6be69a2.0 → 2.0.1-canary.76e35f1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lib/dapp/DAppSigner.d.ts +0 -2
- package/dist/lib/dapp/DAppSigner.js +2 -16
- package/dist/lib/dapp/index.d.ts +5 -7
- package/dist/lib/dapp/index.js +4 -36
- package/dist/lib/shared/index.d.ts +0 -2
- package/dist/lib/shared/index.js +0 -2
- package/dist/lib/shared/payloads.d.ts +1 -1
- package/dist/lib/shared/utils.d.ts +3 -2
- package/dist/lib/shared/utils.js +4 -3
- package/package.json +10 -11
- package/dist/lib/shared/accountInfo.d.ts +0 -30
- package/dist/lib/shared/accountInfo.js +0 -1
- package/dist/lib/shared/mirrorNode.d.ts +0 -3
- package/dist/lib/shared/mirrorNode.js +0 -17
- package/dist/reown/adapter.d.ts +0 -37
- package/dist/reown/adapter.js +0 -255
- package/dist/reown/connectors/HederaConnector.d.ts +0 -29
- package/dist/reown/connectors/HederaConnector.js +0 -35
- package/dist/reown/connectors/index.d.ts +0 -1
- package/dist/reown/connectors/index.js +0 -1
- package/dist/reown/index.d.ts +0 -4
- package/dist/reown/index.js +0 -4
- package/dist/reown/providers/EIP155Provider.d.ts +0 -33
- package/dist/reown/providers/EIP155Provider.js +0 -187
- package/dist/reown/providers/HIP820Provider.d.ts +0 -26
- package/dist/reown/providers/HIP820Provider.js +0 -69
- package/dist/reown/providers/HederaProvider.d.ts +0 -164
- package/dist/reown/providers/HederaProvider.js +0 -471
- package/dist/reown/providers/index.d.ts +0 -3
- package/dist/reown/providers/index.js +0 -3
- package/dist/reown/utils/chains.d.ts +0 -18
- package/dist/reown/utils/chains.js +0 -152
- package/dist/reown/utils/constants.d.ts +0 -16
- package/dist/reown/utils/constants.js +0 -18
- package/dist/reown/utils/helpers.d.ts +0 -12
- package/dist/reown/utils/helpers.js +0 -25
- package/dist/reown/utils/index.d.ts +0 -4
- package/dist/reown/utils/index.js +0 -4
- package/dist/reown/utils/types.d.ts +0 -9
- package/dist/reown/utils/types.js +0 -1
- package/dist/reown/wallets/EIP155Wallet.d.ts +0 -46
- package/dist/reown/wallets/EIP155Wallet.js +0 -136
- package/dist/reown/wallets/HIP820Wallet.d.ts +0 -53
- package/dist/reown/wallets/HIP820Wallet.js +0 -239
- package/dist/reown/wallets/index.d.ts +0 -2
- package/dist/reown/wallets/index.js +0 -2
@@ -1,152 +0,0 @@
|
|
1
|
-
import { WcHelpersUtil } from '@reown/appkit';
|
2
|
-
import { defineChain } from '@reown/appkit/networks';
|
3
|
-
import { mergeArrays, normalizeNamespaces } from '@walletconnect/utils';
|
4
|
-
import { HederaJsonRpcMethod } from '../..';
|
5
|
-
export const hederaNamespace = 'hedera';
|
6
|
-
export const HederaChainDefinition = {
|
7
|
-
Native: {
|
8
|
-
Mainnet: defineChain({
|
9
|
-
id: 'mainnet',
|
10
|
-
chainNamespace: hederaNamespace,
|
11
|
-
caipNetworkId: 'hedera:mainnet',
|
12
|
-
name: 'Hedera Mainnet',
|
13
|
-
nativeCurrency: {
|
14
|
-
symbol: 'ℏ',
|
15
|
-
name: 'HBAR',
|
16
|
-
decimals: 8,
|
17
|
-
},
|
18
|
-
rpcUrls: {
|
19
|
-
default: {
|
20
|
-
http: ['https://mainnet.hashio.io/api'],
|
21
|
-
},
|
22
|
-
},
|
23
|
-
blockExplorers: {
|
24
|
-
default: {
|
25
|
-
name: 'Hashscan',
|
26
|
-
url: 'https://hashscan.io/mainnet',
|
27
|
-
},
|
28
|
-
},
|
29
|
-
testnet: false,
|
30
|
-
}),
|
31
|
-
Testnet: defineChain({
|
32
|
-
id: 'testnet',
|
33
|
-
chainNamespace: hederaNamespace,
|
34
|
-
caipNetworkId: 'hedera:testnet',
|
35
|
-
name: 'Hedera Testnet',
|
36
|
-
nativeCurrency: {
|
37
|
-
symbol: 'ℏ',
|
38
|
-
name: 'HBAR',
|
39
|
-
decimals: 8,
|
40
|
-
},
|
41
|
-
rpcUrls: {
|
42
|
-
default: {
|
43
|
-
http: ['https://testnet.hashio.io/api'],
|
44
|
-
},
|
45
|
-
},
|
46
|
-
blockExplorers: {
|
47
|
-
default: {
|
48
|
-
name: 'Hashscan',
|
49
|
-
url: 'https://hashscan.io/testnet',
|
50
|
-
},
|
51
|
-
},
|
52
|
-
testnet: true,
|
53
|
-
}),
|
54
|
-
},
|
55
|
-
EVM: {
|
56
|
-
Mainnet: defineChain({
|
57
|
-
id: 295,
|
58
|
-
name: 'Hedera Mainnet EVM',
|
59
|
-
chainNamespace: 'eip155',
|
60
|
-
caipNetworkId: 'eip155:295',
|
61
|
-
nativeCurrency: {
|
62
|
-
symbol: 'ℏ',
|
63
|
-
name: 'HBAR',
|
64
|
-
decimals: 18,
|
65
|
-
},
|
66
|
-
rpcUrls: {
|
67
|
-
default: {
|
68
|
-
http: ['https://mainnet.hashio.io/api'],
|
69
|
-
},
|
70
|
-
},
|
71
|
-
blockExplorers: {
|
72
|
-
default: {
|
73
|
-
name: 'Hashscan',
|
74
|
-
url: 'https://hashscan.io/testnet',
|
75
|
-
},
|
76
|
-
},
|
77
|
-
testnet: false,
|
78
|
-
}),
|
79
|
-
Testnet: defineChain({
|
80
|
-
id: 296,
|
81
|
-
name: 'Hedera Testnet EVM',
|
82
|
-
chainNamespace: 'eip155',
|
83
|
-
caipNetworkId: 'eip155:296',
|
84
|
-
nativeCurrency: {
|
85
|
-
symbol: 'ℏ',
|
86
|
-
name: 'HBAR',
|
87
|
-
decimals: 18,
|
88
|
-
},
|
89
|
-
rpcUrls: {
|
90
|
-
default: {
|
91
|
-
http: ['https://testnet.hashio.io/api'],
|
92
|
-
},
|
93
|
-
},
|
94
|
-
blockExplorers: {
|
95
|
-
default: {
|
96
|
-
name: 'Hashscan',
|
97
|
-
url: 'https://hashscan.io/testnet',
|
98
|
-
},
|
99
|
-
},
|
100
|
-
testnet: true,
|
101
|
-
}),
|
102
|
-
},
|
103
|
-
};
|
104
|
-
// Support Hedera Networks
|
105
|
-
export function createNamespaces(caipNetworks) {
|
106
|
-
return caipNetworks.reduce((acc, chain) => {
|
107
|
-
const { id, chainNamespace, rpcUrls } = chain;
|
108
|
-
const rpcUrl = rpcUrls.default.http[0];
|
109
|
-
const methods = chainNamespace == 'hedera'
|
110
|
-
? Object.values(HederaJsonRpcMethod)
|
111
|
-
: WcHelpersUtil.getMethodsByChainNamespace(chainNamespace);
|
112
|
-
if (!acc[chainNamespace]) {
|
113
|
-
acc[chainNamespace] = {
|
114
|
-
methods,
|
115
|
-
events: ['accountsChanged', 'chainChanged'],
|
116
|
-
chains: [],
|
117
|
-
rpcMap: {},
|
118
|
-
};
|
119
|
-
}
|
120
|
-
const caipNetworkId = `${chainNamespace}:${id}`;
|
121
|
-
const namespace = acc[chainNamespace];
|
122
|
-
namespace.chains.push(caipNetworkId);
|
123
|
-
if ((namespace === null || namespace === void 0 ? void 0 : namespace.rpcMap) && rpcUrl) {
|
124
|
-
namespace.rpcMap[id] = rpcUrl;
|
125
|
-
}
|
126
|
-
return acc;
|
127
|
-
}, {});
|
128
|
-
}
|
129
|
-
export function getChainsFromApprovedSession(accounts) {
|
130
|
-
return accounts.map((address) => `${address.split(':')[0]}:${address.split(':')[1]}`);
|
131
|
-
}
|
132
|
-
export function getChainId(chain) {
|
133
|
-
return chain.includes(':') ? chain.split(':')[1] : chain;
|
134
|
-
}
|
135
|
-
export function mergeRequiredOptionalNamespaces(required = {}, optional = {}) {
|
136
|
-
const requiredNamespaces = normalizeNamespaces(required);
|
137
|
-
const optionalNamespaces = normalizeNamespaces(optional);
|
138
|
-
return merge(requiredNamespaces, optionalNamespaces);
|
139
|
-
}
|
140
|
-
function merge(requiredNamespaces, optionalNamespaces) {
|
141
|
-
var _a, _b, _c;
|
142
|
-
const merged = Object.assign({}, requiredNamespaces);
|
143
|
-
for (const [namespace, values] of Object.entries(optionalNamespaces)) {
|
144
|
-
if (!merged[namespace]) {
|
145
|
-
merged[namespace] = values;
|
146
|
-
}
|
147
|
-
else {
|
148
|
-
merged[namespace] = Object.assign(Object.assign(Object.assign({}, merged[namespace]), values), { chains: mergeArrays(values.chains, (_a = merged[namespace]) === null || _a === void 0 ? void 0 : _a.chains), methods: mergeArrays(values.methods || [], ((_b = merged[namespace]) === null || _b === void 0 ? void 0 : _b.methods) || []), events: mergeArrays(values.events || [], ((_c = merged[namespace]) === null || _c === void 0 ? void 0 : _c.events) || []) });
|
149
|
-
}
|
150
|
-
}
|
151
|
-
return merged;
|
152
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
export declare const RPC_URL = "https://rpc.walletconnect.org/v1/";
|
2
|
-
export declare const GENERIC_SUBPROVIDER_NAME = "generic";
|
3
|
-
export declare const BUNDLER_URL = "https://rpc.walletconnect.org/v1/bundler";
|
4
|
-
export declare const PROVIDER_EVENTS: {
|
5
|
-
DEFAULT_CHAIN_CHANGED: string;
|
6
|
-
};
|
7
|
-
export declare enum Eip155JsonRpcMethod {
|
8
|
-
PersonalSign = "personal_sign",
|
9
|
-
Sign = "eth_sign",
|
10
|
-
SignTransaction = "eth_signTransaction",
|
11
|
-
SignTypedData = "eth_signTypedData",
|
12
|
-
SignTypedDataV3 = "eth_signTypedData_v3",
|
13
|
-
SignTypedDataV4 = "eth_signTypedData_v4",
|
14
|
-
SendRawTransaction = "eth_sendRawTransaction",
|
15
|
-
SendTransaction = "eth_sendTransaction"
|
16
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
export const RPC_URL = 'https://rpc.walletconnect.org/v1/';
|
2
|
-
export const GENERIC_SUBPROVIDER_NAME = 'generic';
|
3
|
-
export const BUNDLER_URL = `${RPC_URL}bundler`;
|
4
|
-
export const PROVIDER_EVENTS = {
|
5
|
-
DEFAULT_CHAIN_CHANGED: 'default_chain_changed',
|
6
|
-
};
|
7
|
-
// EIP-155 Wallet Methods
|
8
|
-
export var Eip155JsonRpcMethod;
|
9
|
-
(function (Eip155JsonRpcMethod) {
|
10
|
-
Eip155JsonRpcMethod["PersonalSign"] = "personal_sign";
|
11
|
-
Eip155JsonRpcMethod["Sign"] = "eth_sign";
|
12
|
-
Eip155JsonRpcMethod["SignTransaction"] = "eth_signTransaction";
|
13
|
-
Eip155JsonRpcMethod["SignTypedData"] = "eth_signTypedData";
|
14
|
-
Eip155JsonRpcMethod["SignTypedDataV3"] = "eth_signTypedData_v3";
|
15
|
-
Eip155JsonRpcMethod["SignTypedDataV4"] = "eth_signTypedData_v4";
|
16
|
-
Eip155JsonRpcMethod["SendRawTransaction"] = "eth_sendRawTransaction";
|
17
|
-
Eip155JsonRpcMethod["SendTransaction"] = "eth_sendTransaction";
|
18
|
-
})(Eip155JsonRpcMethod || (Eip155JsonRpcMethod = {}));
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Gets message from various signing request methods by filtering out
|
3
|
-
* a value that is not an address (thus is a message).
|
4
|
-
* If it is a hex string, it gets converted to utf8 string
|
5
|
-
*/
|
6
|
-
export declare function getSignParamsMessage(params: string[]): string;
|
7
|
-
/**
|
8
|
-
* Gets data from various signTypedData request methods by filtering out
|
9
|
-
* a value that is not an address (thus is data).
|
10
|
-
* If data is a string convert it to object
|
11
|
-
*/
|
12
|
-
export declare function getSignTypedDataParamsData(params: string[]): any;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { ethers } from 'ethers';
|
2
|
-
/**
|
3
|
-
* Gets message from various signing request methods by filtering out
|
4
|
-
* a value that is not an address (thus is a message).
|
5
|
-
* If it is a hex string, it gets converted to utf8 string
|
6
|
-
*/
|
7
|
-
export function getSignParamsMessage(params) {
|
8
|
-
const message = params.filter((p) => !ethers.isAddress(p))[0];
|
9
|
-
if (ethers.isHexString(message)) {
|
10
|
-
return ethers.toUtf8String(message);
|
11
|
-
}
|
12
|
-
return message;
|
13
|
-
}
|
14
|
-
/**
|
15
|
-
* Gets data from various signTypedData request methods by filtering out
|
16
|
-
* a value that is not an address (thus is data).
|
17
|
-
* If data is a string convert it to object
|
18
|
-
*/
|
19
|
-
export function getSignTypedDataParamsData(params) {
|
20
|
-
const data = params.filter((p) => !ethers.isAddress(p))[0];
|
21
|
-
if (typeof data === 'string') {
|
22
|
-
return JSON.parse(data);
|
23
|
-
}
|
24
|
-
return data;
|
25
|
-
}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { SignClientTypes } from '@walletconnect/types';
|
2
|
-
export interface EthFilter {
|
3
|
-
address?: string;
|
4
|
-
topics?: Array<string | null>;
|
5
|
-
fromBlock?: string;
|
6
|
-
toBlock?: string;
|
7
|
-
blockHash?: string;
|
8
|
-
}
|
9
|
-
export type WalletRequestEventArgs = Omit<SignClientTypes.EventArguments['session_request'], 'verifyContext'>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import { JsonRpcProvider, BaseWallet as BaseEvmWallet, TransactionResponse, JsonRpcTransactionRequest } from 'ethers';
|
2
|
-
import { JsonRpcError, JsonRpcResult } from '@walletconnect/jsonrpc-utils';
|
3
|
-
import { Eip155JsonRpcMethod, WalletRequestEventArgs } from '..';
|
4
|
-
/**
|
5
|
-
* Types
|
6
|
-
*/
|
7
|
-
interface IInitArgs {
|
8
|
-
privateKey?: string;
|
9
|
-
}
|
10
|
-
export interface EIP155WalletInterface {
|
11
|
-
getPrivateKey(): string;
|
12
|
-
getEvmAddress(): string;
|
13
|
-
connect(provider: JsonRpcProvider): BaseEvmWallet;
|
14
|
-
approveSessionRequest(requestEvent: WalletRequestEventArgs): Promise<JsonRpcResult<any> | JsonRpcError>;
|
15
|
-
rejectSessionRequest(requestEvent: WalletRequestEventArgs): JsonRpcError;
|
16
|
-
[Eip155JsonRpcMethod.PersonalSign](message: string): Promise<string>;
|
17
|
-
[Eip155JsonRpcMethod.Sign](message: string): Promise<string>;
|
18
|
-
[Eip155JsonRpcMethod.SignTypedData](domain: any, types: any, data: any): Promise<string>;
|
19
|
-
[Eip155JsonRpcMethod.SignTypedDataV3](domain: any, types: any, data: any): Promise<string>;
|
20
|
-
[Eip155JsonRpcMethod.SignTypedDataV4](domain: any, types: any, data: any): Promise<string>;
|
21
|
-
[Eip155JsonRpcMethod.SignTransaction](transaction: JsonRpcTransactionRequest, provider: JsonRpcProvider): Promise<string>;
|
22
|
-
[Eip155JsonRpcMethod.SendTransaction](transaction: JsonRpcTransactionRequest, provider: JsonRpcProvider): Promise<TransactionResponse>;
|
23
|
-
[Eip155JsonRpcMethod.SendRawTransaction](rawTransaction: string, provider: JsonRpcProvider): Promise<TransactionResponse>;
|
24
|
-
}
|
25
|
-
/**
|
26
|
-
* Library
|
27
|
-
*/
|
28
|
-
export declare class EIP155Wallet implements EIP155WalletInterface {
|
29
|
-
wallet: BaseEvmWallet;
|
30
|
-
constructor(wallet: BaseEvmWallet);
|
31
|
-
connect(provider: JsonRpcProvider): BaseEvmWallet;
|
32
|
-
personal_sign(message: string): Promise<string>;
|
33
|
-
eth_sign(message: string): Promise<string>;
|
34
|
-
eth_signTypedData(domain: any, types: any, data: any): Promise<string>;
|
35
|
-
eth_signTypedData_v3(domain: any, types: any, data: any): Promise<string>;
|
36
|
-
eth_signTypedData_v4(domain: any, types: any, data: any): Promise<string>;
|
37
|
-
eth_signTransaction(transaction: JsonRpcTransactionRequest, provider: JsonRpcProvider): Promise<string>;
|
38
|
-
eth_sendTransaction(transaction: JsonRpcTransactionRequest, provider: JsonRpcProvider): Promise<TransactionResponse>;
|
39
|
-
eth_sendRawTransaction(rawTransaction: string, provider: JsonRpcProvider): Promise<TransactionResponse>;
|
40
|
-
static init({ privateKey }: IInitArgs): EIP155Wallet;
|
41
|
-
getPrivateKey(): string;
|
42
|
-
getEvmAddress(): string;
|
43
|
-
approveSessionRequest(requestEvent: WalletRequestEventArgs): Promise<JsonRpcError | JsonRpcResult<string>>;
|
44
|
-
rejectSessionRequest(requestEvent: WalletRequestEventArgs): JsonRpcError;
|
45
|
-
}
|
46
|
-
export {};
|
@@ -1,136 +0,0 @@
|
|
1
|
-
import { JsonRpcProvider, Wallet, Transaction, } from 'ethers';
|
2
|
-
import { formatJsonRpcError, formatJsonRpcResult, } from '@walletconnect/jsonrpc-utils';
|
3
|
-
import { getSdkError } from '@walletconnect/utils';
|
4
|
-
import { Eip155JsonRpcMethod, HederaChainDefinition, getSignParamsMessage, getSignTypedDataParamsData, } from '..';
|
5
|
-
/**
|
6
|
-
* Library
|
7
|
-
*/
|
8
|
-
export class EIP155Wallet {
|
9
|
-
constructor(wallet) {
|
10
|
-
this.wallet = wallet;
|
11
|
-
}
|
12
|
-
connect(provider) {
|
13
|
-
return this.wallet.connect(provider);
|
14
|
-
}
|
15
|
-
personal_sign(message) {
|
16
|
-
return this.eth_sign(message);
|
17
|
-
}
|
18
|
-
eth_sign(message) {
|
19
|
-
return this.wallet.signMessage(message);
|
20
|
-
}
|
21
|
-
eth_signTypedData(domain, types, data) {
|
22
|
-
return this.wallet.signTypedData(domain, types, data);
|
23
|
-
}
|
24
|
-
eth_signTypedData_v3(domain, types, data) {
|
25
|
-
return this.eth_signTypedData(domain, types, data);
|
26
|
-
}
|
27
|
-
eth_signTypedData_v4(domain, types, data) {
|
28
|
-
return this.eth_signTypedData(domain, types, data);
|
29
|
-
}
|
30
|
-
async eth_signTransaction(transaction, provider) {
|
31
|
-
console.log({ transaction });
|
32
|
-
// Populate transaction
|
33
|
-
const preparedTransaction = await this.connect(provider).populateTransaction(transaction);
|
34
|
-
delete preparedTransaction.from;
|
35
|
-
const txObj = Transaction.from(preparedTransaction);
|
36
|
-
return this.wallet.signTransaction(txObj);
|
37
|
-
}
|
38
|
-
eth_sendTransaction(transaction, provider) {
|
39
|
-
return this.connect(provider).sendTransaction(transaction);
|
40
|
-
}
|
41
|
-
eth_sendRawTransaction(rawTransaction, provider) {
|
42
|
-
return provider.broadcastTransaction(rawTransaction);
|
43
|
-
}
|
44
|
-
static init({ privateKey }) {
|
45
|
-
const wallet = privateKey ? new Wallet(privateKey) : Wallet.createRandom();
|
46
|
-
return new EIP155Wallet(wallet);
|
47
|
-
}
|
48
|
-
getPrivateKey() {
|
49
|
-
return this.wallet.privateKey;
|
50
|
-
}
|
51
|
-
getEvmAddress() {
|
52
|
-
return this.wallet.address;
|
53
|
-
}
|
54
|
-
async approveSessionRequest(requestEvent) {
|
55
|
-
const { params, id } = requestEvent;
|
56
|
-
const { chainId, request } = params;
|
57
|
-
const networks = Object.values(HederaChainDefinition.EVM);
|
58
|
-
const caipNetwork = networks.find((network) => network.caipNetworkId == chainId);
|
59
|
-
if (!caipNetwork) {
|
60
|
-
return formatJsonRpcError(id, 'Unsupported network');
|
61
|
-
}
|
62
|
-
switch (request.method) {
|
63
|
-
case Eip155JsonRpcMethod.PersonalSign:
|
64
|
-
case Eip155JsonRpcMethod.Sign:
|
65
|
-
try {
|
66
|
-
const message = getSignParamsMessage(request.params);
|
67
|
-
const signedMessage = await this.eth_sign(message);
|
68
|
-
return formatJsonRpcResult(id, signedMessage);
|
69
|
-
}
|
70
|
-
catch (error) {
|
71
|
-
console.error(error);
|
72
|
-
if (!(error instanceof Error)) {
|
73
|
-
return formatJsonRpcError(id, 'Failed to sign message');
|
74
|
-
}
|
75
|
-
alert(error.message);
|
76
|
-
return formatJsonRpcError(id, error.message);
|
77
|
-
}
|
78
|
-
case Eip155JsonRpcMethod.SignTypedData:
|
79
|
-
case Eip155JsonRpcMethod.SignTypedDataV3:
|
80
|
-
case Eip155JsonRpcMethod.SignTypedDataV4:
|
81
|
-
try {
|
82
|
-
const { domain, types, message: data } = getSignTypedDataParamsData(request.params);
|
83
|
-
// https://github.com/ethers-io/ethers.js/issues/687#issuecomment-714069471
|
84
|
-
delete types.EIP712Domain;
|
85
|
-
const signedData = await this.eth_signTypedData(domain, types, data);
|
86
|
-
return formatJsonRpcResult(id, signedData);
|
87
|
-
}
|
88
|
-
catch (error) {
|
89
|
-
console.error(error);
|
90
|
-
if (!(error instanceof Error)) {
|
91
|
-
return formatJsonRpcError(id, 'Failed to sign typed data');
|
92
|
-
}
|
93
|
-
alert(error.message);
|
94
|
-
return formatJsonRpcError(id, error.message);
|
95
|
-
}
|
96
|
-
case Eip155JsonRpcMethod.SendRawTransaction:
|
97
|
-
case Eip155JsonRpcMethod.SendTransaction:
|
98
|
-
try {
|
99
|
-
const provider = new JsonRpcProvider(caipNetwork.rpcUrls.default.http[0]);
|
100
|
-
const sendTransaction = request.params[0];
|
101
|
-
const txResponse = await this[request.method](sendTransaction, provider);
|
102
|
-
const txHash = typeof txResponse === 'string' ? txResponse : txResponse === null || txResponse === void 0 ? void 0 : txResponse.hash;
|
103
|
-
const txReceipt = await txResponse.wait();
|
104
|
-
console.log(`Transaction broadcasted on chain ${chainId} , ${{
|
105
|
-
txHash,
|
106
|
-
}}, status: ${txReceipt === null || txReceipt === void 0 ? void 0 : txReceipt.status}`);
|
107
|
-
return formatJsonRpcResult(id, txHash);
|
108
|
-
}
|
109
|
-
catch (error) {
|
110
|
-
console.error(error);
|
111
|
-
return formatJsonRpcError(id, error instanceof Error ? error.message : 'Failed to send transaction');
|
112
|
-
}
|
113
|
-
case Eip155JsonRpcMethod.SignTransaction:
|
114
|
-
try {
|
115
|
-
const provider = new JsonRpcProvider(caipNetwork.rpcUrls.default.http[0]);
|
116
|
-
const signTransaction = request.params[0];
|
117
|
-
const signature = await this.eth_signTransaction(signTransaction, provider);
|
118
|
-
return formatJsonRpcResult(id, signature);
|
119
|
-
}
|
120
|
-
catch (error) {
|
121
|
-
console.error(error);
|
122
|
-
if (!(error instanceof Error)) {
|
123
|
-
return formatJsonRpcError(id, 'Failed to sign transaction');
|
124
|
-
}
|
125
|
-
alert(error.message);
|
126
|
-
return formatJsonRpcError(id, error.message);
|
127
|
-
}
|
128
|
-
default:
|
129
|
-
throw new Error(getSdkError('INVALID_METHOD').message);
|
130
|
-
}
|
131
|
-
}
|
132
|
-
rejectSessionRequest(requestEvent) {
|
133
|
-
const { id } = requestEvent;
|
134
|
-
return formatJsonRpcError(id, getSdkError('USER_REJECTED').message);
|
135
|
-
}
|
136
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import { Wallet as HederaWallet, AccountId, Transaction, Query } from '@hashgraph/sdk';
|
2
|
-
import { JsonRpcError, JsonRpcResult } from '@walletconnect/jsonrpc-utils';
|
3
|
-
import { HederaChainId, HederaJsonRpcMethod, GetNodeAddressesResult, ExecuteTransactionResult, SignAndExecuteQueryResult, SignMessageResult, SignAndExecuteTransactionResult, SignTransactionResult, WalletRequestEventArgs } from '../..';
|
4
|
-
import Provider from '../../lib/wallet/provider';
|
5
|
-
interface IInitArgs {
|
6
|
-
chainId: HederaChainId;
|
7
|
-
accountId: AccountId | string;
|
8
|
-
privateKey: string;
|
9
|
-
_provider?: Provider;
|
10
|
-
}
|
11
|
-
export interface HIP820WalletInterface {
|
12
|
-
approveSessionRequest(requestEvent: WalletRequestEventArgs): Promise<JsonRpcResult<any> | JsonRpcError>;
|
13
|
-
rejectSessionRequest(requestEvent: WalletRequestEventArgs): JsonRpcError;
|
14
|
-
getHederaWallet(): HederaWallet;
|
15
|
-
[HederaJsonRpcMethod.GetNodeAddresses](id: number, _: any): Promise<GetNodeAddressesResult>;
|
16
|
-
[HederaJsonRpcMethod.ExecuteTransaction](id: number, body: Transaction): Promise<ExecuteTransactionResult | JsonRpcError>;
|
17
|
-
[HederaJsonRpcMethod.SignMessage](id: number, body: string): Promise<SignMessageResult>;
|
18
|
-
[HederaJsonRpcMethod.SignAndExecuteQuery](id: number, body: Query<any>): Promise<SignAndExecuteQueryResult | JsonRpcError>;
|
19
|
-
[HederaJsonRpcMethod.SignAndExecuteTransaction](id: number, body: Transaction): Promise<SignAndExecuteTransactionResult | JsonRpcError>;
|
20
|
-
[HederaJsonRpcMethod.SignTransaction](id: number, body: Uint8Array): Promise<SignTransactionResult>;
|
21
|
-
}
|
22
|
-
export declare class HIP820Wallet implements HIP820WalletInterface {
|
23
|
-
wallet: HederaWallet;
|
24
|
-
constructor(wallet: HederaWallet);
|
25
|
-
getHederaWallet(): HederaWallet;
|
26
|
-
static init({ chainId, accountId, privateKey, _provider }: IInitArgs): HIP820Wallet;
|
27
|
-
validateParam(name: string, value: any, expectedType: string): void;
|
28
|
-
parseSessionRequest(event: WalletRequestEventArgs, shouldThrow?: boolean): {
|
29
|
-
method: HederaJsonRpcMethod;
|
30
|
-
chainId: HederaChainId;
|
31
|
-
id: number;
|
32
|
-
topic: string;
|
33
|
-
body?: Transaction | Query<any> | string | Uint8Array | undefined;
|
34
|
-
accountId?: AccountId;
|
35
|
-
};
|
36
|
-
approveSessionRequest(event: WalletRequestEventArgs): Promise<JsonRpcResult<any> | JsonRpcError>;
|
37
|
-
rejectSessionRequest(requestEvent: WalletRequestEventArgs): JsonRpcError;
|
38
|
-
hedera_getNodeAddresses(id: number, _: any): Promise<JsonRpcResult<{
|
39
|
-
nodes: string[];
|
40
|
-
}>>;
|
41
|
-
hedera_executeTransaction(id: number, signedTransaction: Transaction): Promise<ExecuteTransactionResult | JsonRpcError>;
|
42
|
-
hedera_signMessage(id: number, body: string): Promise<JsonRpcResult<{
|
43
|
-
signatureMap: string;
|
44
|
-
}>>;
|
45
|
-
hedera_signAndExecuteQuery(id: number, body: Query<any>): Promise<JsonRpcError | JsonRpcResult<{
|
46
|
-
response: string;
|
47
|
-
}>>;
|
48
|
-
hedera_signAndExecuteTransaction(id: number, transaction: Transaction): Promise<JsonRpcError | JsonRpcResult<import("@hashgraph/sdk/lib/transaction/TransactionResponse").TransactionResponseJSON>>;
|
49
|
-
hedera_signTransaction(id: number, body: Uint8Array): Promise<JsonRpcResult<{
|
50
|
-
signatureMap: string;
|
51
|
-
}>>;
|
52
|
-
}
|
53
|
-
export default HIP820Wallet;
|