@hashgraph/hedera-wallet-connect 1.3.7-canary.6c467f9.0 → 1.3.7-canary.76acea8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/dist/{src/lib/dapp → dapp}/DAppSigner.d.ts +15 -1
  2. package/dist/{src/lib/dapp → dapp}/DAppSigner.js +106 -30
  3. package/dist/{src/lib/dapp → dapp}/index.d.ts +4 -0
  4. package/dist/{src/lib/dapp → dapp}/index.js +43 -47
  5. package/dist/{src/lib/shared → shared}/logger.d.ts +1 -0
  6. package/dist/{src/lib/shared → shared}/logger.js +3 -0
  7. package/dist/{src/lib/shared → shared}/utils.d.ts +2 -2
  8. package/dist/{src/lib/shared → shared}/utils.js +2 -2
  9. package/package.json +5 -2
  10. package/dist/src/index.d.ts +0 -1
  11. package/dist/src/index.js +0 -20
  12. package/dist/test/_helpers.d.ts +0 -38
  13. package/dist/test/_helpers.js +0 -95
  14. package/dist/test/dapp/DAppConnector.test.d.ts +0 -1
  15. package/dist/test/dapp/DAppConnector.test.js +0 -234
  16. package/dist/test/dapp/DAppSigner.test.d.ts +0 -1
  17. package/dist/test/dapp/DAppSigner.test.js +0 -155
  18. package/dist/test/utils.test.d.ts +0 -1
  19. package/dist/test/utils.test.js +0 -201
  20. package/dist/test/wallet/methods/wallet-executeTransaction.test.d.ts +0 -1
  21. package/dist/test/wallet/methods/wallet-executeTransaction.test.js +0 -43
  22. package/dist/test/wallet/methods/wallet-getNodeAddresses.test.d.ts +0 -1
  23. package/dist/test/wallet/methods/wallet-getNodeAddresses.test.js +0 -40
  24. package/dist/test/wallet/methods/wallet-signAndExecuteQuery.test.d.ts +0 -1
  25. package/dist/test/wallet/methods/wallet-signAndExecuteQuery.test.js +0 -41
  26. package/dist/test/wallet/methods/wallet-signAndExecuteTransaction.test.d.ts +0 -1
  27. package/dist/test/wallet/methods/wallet-signAndExecuteTransaction.test.js +0 -48
  28. package/dist/test/wallet/methods/wallet-signMessage.test.d.ts +0 -1
  29. package/dist/test/wallet/methods/wallet-signMessage.test.js +0 -60
  30. package/dist/test/wallet/methods/wallet-signTransaction.test.d.ts +0 -1
  31. package/dist/test/wallet/methods/wallet-signTransaction.test.js +0 -47
  32. package/dist/test/wallet/wallet-init.test.d.ts +0 -1
  33. package/dist/test/wallet/wallet-init.test.js +0 -53
  34. /package/dist/{src/lib/index.d.ts → index.d.ts} +0 -0
  35. /package/dist/{src/lib/index.js → index.js} +0 -0
  36. /package/dist/{src/lib/shared → shared}/chainIds.d.ts +0 -0
  37. /package/dist/{src/lib/shared → shared}/chainIds.js +0 -0
  38. /package/dist/{src/lib/shared → shared}/errors.d.ts +0 -0
  39. /package/dist/{src/lib/shared → shared}/errors.js +0 -0
  40. /package/dist/{src/lib/shared → shared}/events.d.ts +0 -0
  41. /package/dist/{src/lib/shared → shared}/events.js +0 -0
  42. /package/dist/{src/lib/shared → shared}/extensionController.d.ts +0 -0
  43. /package/dist/{src/lib/shared → shared}/extensionController.js +0 -0
  44. /package/dist/{src/lib/shared → shared}/index.d.ts +0 -0
  45. /package/dist/{src/lib/shared → shared}/index.js +0 -0
  46. /package/dist/{src/lib/shared → shared}/methods.d.ts +0 -0
  47. /package/dist/{src/lib/shared → shared}/methods.js +0 -0
  48. /package/dist/{src/lib/shared → shared}/payloads.d.ts +0 -0
  49. /package/dist/{src/lib/shared → shared}/payloads.js +0 -0
  50. /package/dist/{src/lib/wallet → wallet}/index.d.ts +0 -0
  51. /package/dist/{src/lib/wallet → wallet}/index.js +0 -0
  52. /package/dist/{src/lib/wallet → wallet}/provider.d.ts +0 -0
  53. /package/dist/{src/lib/wallet → wallet}/provider.js +0 -0
  54. /package/dist/{src/lib/wallet → wallet}/types.d.ts +0 -0
  55. /package/dist/{src/lib/wallet → wallet}/types.js +0 -0
@@ -1,40 +0,0 @@
1
- /*
2
- *
3
- * Hedera Wallet Connect
4
- *
5
- * Copyright (C) 2023 Hedera Hashgraph, LLC
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import { HederaChainId, Wallet } from '../../../src';
21
- import { projectId, requestId, requestTopic, testPrivateKeyECDSA, testUserAccountId, useJsonFixture, walletMetadata, } from '../../_helpers';
22
- describe(Wallet.name, () => {
23
- describe('getNodeAddresses', () => {
24
- it('should return array of nodes addresses', async () => {
25
- const wallet = await Wallet.create(projectId, walletMetadata);
26
- const hederaWallet = wallet.getHederaWallet(HederaChainId.Testnet, testUserAccountId.toString(), testPrivateKeyECDSA);
27
- const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest');
28
- try {
29
- await wallet.hedera_getNodeAddresses(requestId, requestTopic, null, hederaWallet);
30
- }
31
- catch (err) { }
32
- const mockResponse = useJsonFixture('methods/getNodeAddressesSuccess');
33
- const callArguments = respondSessionRequestSpy.mock.calls[0][0];
34
- const response = callArguments;
35
- response.response.result.nodes.sort();
36
- mockResponse.response.result.nodes.sort();
37
- expect(response).toEqual(mockResponse);
38
- }, 15000);
39
- });
40
- });
@@ -1,41 +0,0 @@
1
- /*
2
- *
3
- * Hedera Wallet Connect
4
- *
5
- * Copyright (C) 2023 Hedera Hashgraph, LLC
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import { AccountInfoQuery } from '@hashgraph/sdk';
21
- import { HederaChainId, Wallet, base64StringToUint8Array, } from '../../../src';
22
- import { projectId, requestId, requestTopic, testPrivateKeyECDSA, testUserAccountId, useJsonFixture, walletMetadata, } from '../../_helpers';
23
- describe(Wallet.name, () => {
24
- describe('signAndExecuteQuery', () => {
25
- it('should sign and execute query, returning the query response', async () => {
26
- const wallet = await Wallet.create(projectId, walletMetadata);
27
- const hederaWallet = wallet.getHederaWallet(HederaChainId.Testnet, testUserAccountId.toString(), testPrivateKeyECDSA);
28
- const query = new AccountInfoQuery().setAccountId(testUserAccountId);
29
- const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest');
30
- const signerCallMock = jest.spyOn(query, 'executeWithSigner');
31
- const toBytes = () => base64StringToUint8Array(btoa('Hello World!'));
32
- signerCallMock.mockImplementation(async () => ({ toBytes }));
33
- try {
34
- await wallet.hedera_signAndExecuteQuery(requestId, requestTopic, query, hederaWallet);
35
- }
36
- catch (err) { }
37
- const mockResponse = useJsonFixture('methods/signAndExecuteQuerySuccess');
38
- expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse);
39
- }, 15000);
40
- });
41
- });
@@ -1,48 +0,0 @@
1
- /*
2
- *
3
- * Hedera Wallet Connect
4
- *
5
- * Copyright (C) 2023 Hedera Hashgraph, LLC
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import { TopicCreateTransaction } from '@hashgraph/sdk';
21
- import { HederaChainId, Wallet } from '../../../src';
22
- import { prepareTestTransaction, projectId, requestId, requestTopic, testPrivateKeyECDSA, testUserAccountId, useJsonFixture, walletMetadata, } from '../../_helpers';
23
- describe(Wallet.name, () => {
24
- describe('signAndExecuteTransaction', () => {
25
- it('should sign and execute, returning the transaction response', async () => {
26
- try {
27
- const wallet = await Wallet.create(projectId, walletMetadata);
28
- const hederaWallet = wallet.getHederaWallet(HederaChainId.Testnet, testUserAccountId.toString(), testPrivateKeyECDSA);
29
- const signerCallMock = jest.spyOn(hederaWallet, 'call');
30
- signerCallMock.mockImplementation(async () => {
31
- return {
32
- nodeId: '0.0.3',
33
- transactionHash: 'uO6obRah/zbL1Wn1ZVd5unos7kbsI8G5bHifKGVWUGZPiCafQzr/hdlEJyUiKLw9',
34
- transactionId: '0.0.12345@1691705630.325343432',
35
- };
36
- }); // Mocking the 'call' method to do nothing
37
- const transaction = prepareTestTransaction(new TopicCreateTransaction(), {
38
- freeze: true,
39
- });
40
- const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest');
41
- await wallet.hedera_signAndExecuteTransaction(requestId, requestTopic, transaction, hederaWallet);
42
- const mockResponse = useJsonFixture('methods/signAndExecuteTransactionSuccess');
43
- expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse);
44
- }
45
- catch (err) { }
46
- }, 15000);
47
- });
48
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,60 +0,0 @@
1
- /*
2
- *
3
- * Hedera Wallet Connect
4
- *
5
- * Copyright (C) 2023 Hedera Hashgraph, LLC
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import { HederaChainId, Wallet } from '../../../src';
21
- import { testPrivateKeyECDSA, testPrivateKeyED25519, testUserAccountId, walletMetadata, projectId, } from '../../_helpers';
22
- describe(Wallet.name, () => {
23
- describe('signMessage', () => {
24
- // [private key type, private key, expected value]
25
- const testCases = [
26
- [
27
- 'ECDSA',
28
- testPrivateKeyECDSA,
29
- 'CmUKIQJ4J53yGuPNMGEGJ7HkI+u3QFxUuAOa9VLEtFj7Y6qNMzJAp3vxT7kRPE9HFFm/bbArGYDQ+psNWZC70rdW2bE1L86REC5xavtsalXfGaZ7FsdkWwPg4GBUKuzmr1eFTcYdNg==',
30
- ],
31
- [
32
- 'ED25519',
33
- testPrivateKeyED25519,
34
- 'CmQKIKLvE3YbZEplGhpKxmbq+6xBnJcoL4r1wz9Y1zLnPlpVGkBtfDTfBZGf/MUbovYyLUjORErDGhDYbzPFoAbkMwRrpw2ouDRmn6Dd6A06k6yM/FhZ/VjdHVhQUd+fxv1cZqUM',
35
- ],
36
- ];
37
- test.each(testCases)('should decode message bytes and sign with: %p', async (_, privateKey, expected) => {
38
- const wallet = await Wallet.create(projectId, walletMetadata);
39
- const id = 1;
40
- const topic = 'test-topic';
41
- const hederaWallet = wallet.getHederaWallet(HederaChainId.Testnet, testUserAccountId.toString(), privateKey);
42
- const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest');
43
- try {
44
- await wallet.hedera_signMessage(id, topic, 'Hello Future', hederaWallet);
45
- }
46
- catch (err) { }
47
- const mockResponse = {
48
- topic,
49
- response: {
50
- jsonrpc: '2.0',
51
- id,
52
- result: {
53
- signatureMap: expected,
54
- },
55
- },
56
- };
57
- expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse);
58
- });
59
- });
60
- });
@@ -1,47 +0,0 @@
1
- /*
2
- *
3
- * Hedera Wallet Connect
4
- *
5
- * Copyright (C) 2023 Hedera Hashgraph, LLC
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import { TransferTransaction, Hbar, AccountId } from '@hashgraph/sdk';
21
- import { HederaChainId, Wallet, transactionToTransactionBody, } from '../../../src';
22
- import { projectId, requestId, requestTopic, testPrivateKeyECDSA, testUserAccountId, useJsonFixture, walletMetadata, } from '../../_helpers';
23
- describe(Wallet.name, () => {
24
- describe('signTransaction', () => {
25
- it('should sign a transaction and return without executing', async () => {
26
- try {
27
- const wallet = await Wallet.create(projectId, walletMetadata);
28
- const hederaWallet = wallet.getHederaWallet(HederaChainId.Testnet, testUserAccountId.toString(), testPrivateKeyECDSA);
29
- const transaction = new TransferTransaction()
30
- .setMaxTransactionFee(new Hbar(1))
31
- .addHbarTransfer('0.0.123', new Hbar(10))
32
- .addHbarTransfer('0.0.321', new Hbar(-10));
33
- const transactionBody = transactionToTransactionBody(transaction, AccountId.fromString('0.0.3'));
34
- if (!transactionBody)
35
- throw new Error('Failed to create transaction body');
36
- const respondSessionRequestSpy = jest.spyOn(wallet, 'respondSessionRequest');
37
- const response = await wallet.hedera_signTransaction(requestId, requestTopic, transactionBody, hederaWallet);
38
- console.log(response);
39
- const mockResponse = useJsonFixture('methods/signTransactionSuccess');
40
- mockResponse.response.result;
41
- respondSessionRequestSpy;
42
- expect(respondSessionRequestSpy).toHaveBeenCalledWith(mockResponse);
43
- }
44
- catch (err) { }
45
- }, 15000);
46
- });
47
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
1
- /*
2
- *
3
- * Hedera Wallet Connect
4
- *
5
- * Copyright (C) 2023 Hedera Hashgraph, LLC
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import { Wallet as HederaWallet, LedgerId } from '@hashgraph/sdk';
21
- import { HederaChainId, Wallet } from '../../src';
22
- import { defaultAccountNumber, projectId, testPrivateKeyECDSA, walletMetadata, } from '../_helpers';
23
- describe(Wallet.name, () => {
24
- describe('create', () => {
25
- let wallet;
26
- beforeAll(async () => {
27
- wallet = await Wallet.create(projectId, walletMetadata);
28
- });
29
- it('should create Wallet instance with a projectId and walletMetadata', async () => {
30
- expect(wallet).toBeInstanceOf(Wallet);
31
- expect(wallet.metadata).toBe(walletMetadata);
32
- expect(wallet.core.projectId).toBe(projectId);
33
- });
34
- describe('getHederaWallet', () => {
35
- // [HederaChainId, accountId, LedgerId]
36
- const testCases = [
37
- [HederaChainId.Mainnet, defaultAccountNumber, LedgerId.MAINNET],
38
- [HederaChainId.Previewnet, defaultAccountNumber, LedgerId.PREVIEWNET],
39
- [HederaChainId.Testnet, defaultAccountNumber, LedgerId.TESTNET],
40
- [HederaChainId.Mainnet, `0.0.${defaultAccountNumber}`, LedgerId.MAINNET],
41
- [HederaChainId.Previewnet, `0.0.${defaultAccountNumber}`, LedgerId.PREVIEWNET],
42
- [HederaChainId.Testnet, `0.0.${defaultAccountNumber}`, LedgerId.TESTNET],
43
- ];
44
- test.each(testCases)('it should initialize HederaWallet with %p chainId and %p accountId', async (chainId, accountId, ledgerId) => {
45
- const hederaWallet = wallet.getHederaWallet(chainId, accountId.toString(), testPrivateKeyECDSA);
46
- expect(wallet).toBeInstanceOf(Wallet);
47
- expect(hederaWallet).toBeInstanceOf(HederaWallet);
48
- expect(hederaWallet.accountId.toString()).toBe(`0.0.${defaultAccountNumber}`);
49
- expect(hederaWallet.provider.getLedgerId()).toBe(ledgerId);
50
- });
51
- });
52
- });
53
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes