@hashgraphonline/hashinal-wc 1.0.71 → 1.0.73
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 -4
- package/dist/es/hashinal-wc.es.js +52 -8
- package/dist/es/hashinal-wc.es.js.map +1 -1
- package/dist/es/index.d.ts +7 -1
- package/dist/es/sign/index.d.ts +1 -0
- package/dist/es/types.d.ts +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/sign/index.d.ts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/umd/hashinal-wc.umd.js +3 -3
- package/dist/umd/hashinal-wc.umd.js.map +1 -1
- package/dist/umd/index.d.ts +7 -1
- package/dist/umd/sign/index.d.ts +1 -0
- package/dist/umd/types.d.ts +1 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ This SDK provides a simple interface for interacting with the Hedera Hashgraph u
|
|
|
26
26
|
No installation needed. Reference the script directly in your HTML:
|
|
27
27
|
|
|
28
28
|
```html
|
|
29
|
-
<script data-src="hcs://1/0.0.
|
|
29
|
+
<script data-src="hcs://1/0.0.7337015" data-script-id="wallet-connect"></script>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### For NPM projects (ESM)
|
|
@@ -34,7 +34,7 @@ No installation needed. Reference the script directly in your HTML:
|
|
|
34
34
|
Install the package:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
npm install @
|
|
37
|
+
npm install @hashgraph/hashinal-wc @hashgraph/sdk @hashgraph/proto @hashgraph/hedera-wallet-connect @walletconnect/modal @walletconnect/qrcode-modal @walletconnect/utils @walletconnect/types @walletconnect/modal-core fetch-retry
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Usage
|
|
@@ -52,7 +52,7 @@ const sdk = window.HashinalsWalletConnectSDK;
|
|
|
52
52
|
Import and use the SDK:
|
|
53
53
|
|
|
54
54
|
```javascript
|
|
55
|
-
import { HashinalsWalletConnectSDK } from '@
|
|
55
|
+
import { HashinalsWalletConnectSDK } from '@hashgraph/hashinal-wc';
|
|
56
56
|
const sdk = HashinalsWalletConnectSDK.getInstance();
|
|
57
57
|
```
|
|
58
58
|
|
|
@@ -78,7 +78,7 @@ await window.HashinalsWalletConnectSDK.init(projectId, metadata);
|
|
|
78
78
|
ESM Example:
|
|
79
79
|
|
|
80
80
|
```javascript
|
|
81
|
-
import { HashinalsWalletConnectSDK } from '@
|
|
81
|
+
import { HashinalsWalletConnectSDK } from '@hashgraph/hashinal-wc';
|
|
82
82
|
import { LedgerId } from '@hashgraph/sdk';
|
|
83
83
|
|
|
84
84
|
const sdk = HashinalsWalletConnectSDK.getInstance();
|
|
@@ -529,6 +529,7 @@ Version 1.0.58 and onward correlate with the NPM Package version.
|
|
|
529
529
|
| v1.0.58 | 0.0.7001143 | UMD |
|
|
530
530
|
| v1.0.62 | 0.0.7111719 | UMD |
|
|
531
531
|
| v1.0.64 | 0.0.7153927 | UMD |
|
|
532
|
+
| v1.0.71 | 0.0.7337015 | UMD |
|
|
532
533
|
|
|
533
534
|
## Contributing
|
|
534
535
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as HashgraphSDK from "@hashgraph/sdk";
|
|
2
2
|
import { LedgerId, TopicMessageSubmitTransaction, TopicId, TransferTransaction, TransactionId, AccountId, Hbar, ContractExecuteTransaction, ContractId, TopicCreateTransaction, PrivateKey, TokenCreateTransaction, TokenType, TokenSupplyType, TokenMintTransaction, TokenId, AccountCreateTransaction, TokenAssociateTransaction, TokenDissociateTransaction, AccountUpdateTransaction, AccountAllowanceApproveTransaction } from "@hashgraph/sdk";
|
|
3
3
|
import { DAppConnector, HederaJsonRpcMethod, HederaSessionEvent, HederaChainId } from "@hashgraph/hedera-wallet-connect";
|
|
4
|
+
import { base64StringToSignatureMap, prefixMessageToSign, verifyMessageSignature } from "@hashgraph/hedera-wallet-connect";
|
|
4
5
|
import retryFetch from "fetch-retry";
|
|
5
6
|
var buffer = {};
|
|
6
7
|
var base64Js = {};
|
|
@@ -1809,6 +1810,9 @@ var Result = /* @__PURE__ */ ((Result2) => {
|
|
|
1809
1810
|
return Result2;
|
|
1810
1811
|
})(Result || {});
|
|
1811
1812
|
class HashinalsWalletConnectSDK {
|
|
1813
|
+
get dAppConnector() {
|
|
1814
|
+
return HashinalsWalletConnectSDK.dAppConnectorInstance;
|
|
1815
|
+
}
|
|
1812
1816
|
constructor(logger, network) {
|
|
1813
1817
|
this.logger = logger || new DefaultLogger();
|
|
1814
1818
|
this.network = network || LedgerId.MAINNET;
|
|
@@ -1846,22 +1850,26 @@ class HashinalsWalletConnectSDK {
|
|
|
1846
1850
|
async init(projectId, metadata, network) {
|
|
1847
1851
|
const chosenNetwork = network || this.network;
|
|
1848
1852
|
const isMainnet = chosenNetwork.toString() === "mainnet";
|
|
1849
|
-
|
|
1853
|
+
if (HashinalsWalletConnectSDK.dAppConnectorInstance) {
|
|
1854
|
+
return HashinalsWalletConnectSDK.dAppConnectorInstance;
|
|
1855
|
+
}
|
|
1856
|
+
HashinalsWalletConnectSDK.dAppConnectorInstance = new DAppConnector(
|
|
1850
1857
|
metadata,
|
|
1851
1858
|
chosenNetwork,
|
|
1852
1859
|
projectId,
|
|
1853
1860
|
Object.values(HederaJsonRpcMethod),
|
|
1854
1861
|
[HederaSessionEvent.ChainChanged, HederaSessionEvent.AccountsChanged],
|
|
1855
|
-
[isMainnet ? HederaChainId.Mainnet : HederaChainId.Testnet]
|
|
1862
|
+
[isMainnet ? HederaChainId.Mainnet : HederaChainId.Testnet],
|
|
1863
|
+
"debug"
|
|
1856
1864
|
);
|
|
1857
|
-
await
|
|
1858
|
-
|
|
1865
|
+
await HashinalsWalletConnectSDK.dAppConnectorInstance.init({ logger: "error" });
|
|
1866
|
+
HashinalsWalletConnectSDK.dAppConnectorInstance.onSessionIframeCreated = (session) => {
|
|
1859
1867
|
this.handleNewSession(session);
|
|
1860
1868
|
};
|
|
1861
1869
|
this.logger.info(
|
|
1862
1870
|
`Hedera Wallet Connect SDK initialized on ${chosenNetwork}`
|
|
1863
1871
|
);
|
|
1864
|
-
return
|
|
1872
|
+
return HashinalsWalletConnectSDK.dAppConnectorInstance;
|
|
1865
1873
|
}
|
|
1866
1874
|
async connect() {
|
|
1867
1875
|
this.ensureInitialized();
|
|
@@ -1870,10 +1878,29 @@ class HashinalsWalletConnectSDK {
|
|
|
1870
1878
|
return session;
|
|
1871
1879
|
}
|
|
1872
1880
|
async disconnect() {
|
|
1881
|
+
var _a, _b;
|
|
1882
|
+
try {
|
|
1883
|
+
this.ensureInitialized();
|
|
1884
|
+
const accountInfo = this.getAccountInfo();
|
|
1885
|
+
const accountId = accountInfo == null ? void 0 : accountInfo.accountId;
|
|
1886
|
+
const network = accountInfo == null ? void 0 : accountInfo.network;
|
|
1887
|
+
const signer = (_a = this == null ? void 0 : this.dAppConnector) == null ? void 0 : _a.signers.find(
|
|
1888
|
+
(signer_) => signer_.getAccountId().toString() === accountId
|
|
1889
|
+
);
|
|
1890
|
+
await ((_b = this.dAppConnector) == null ? void 0 : _b.disconnect(signer == null ? void 0 : signer.topic));
|
|
1891
|
+
this.logger.info(`Disconnected from ${accountId} on ${network}`);
|
|
1892
|
+
return true;
|
|
1893
|
+
} catch (e) {
|
|
1894
|
+
this.logger.error("Failed to disconnect", e);
|
|
1895
|
+
return false;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
async disconnectAll() {
|
|
1899
|
+
var _a;
|
|
1873
1900
|
try {
|
|
1874
1901
|
this.ensureInitialized();
|
|
1875
|
-
await this.dAppConnector.disconnectAll();
|
|
1876
|
-
this.logger.info(
|
|
1902
|
+
await ((_a = this.dAppConnector) == null ? void 0 : _a.disconnectAll());
|
|
1903
|
+
this.logger.info(`Disconnected from all wallets`);
|
|
1877
1904
|
return true;
|
|
1878
1905
|
} catch (e) {
|
|
1879
1906
|
this.logger.error("Failed to disconnect", e);
|
|
@@ -2138,6 +2165,20 @@ class HashinalsWalletConnectSDK {
|
|
|
2138
2165
|
};
|
|
2139
2166
|
}
|
|
2140
2167
|
}
|
|
2168
|
+
async signMessage(message) {
|
|
2169
|
+
const dAppConnector = this.dAppConnector;
|
|
2170
|
+
if (!dAppConnector) {
|
|
2171
|
+
throw new Error("No active connection or signer");
|
|
2172
|
+
}
|
|
2173
|
+
const accountInfo = this.getAccountInfo();
|
|
2174
|
+
const accountId = accountInfo == null ? void 0 : accountInfo.accountId;
|
|
2175
|
+
const params = {
|
|
2176
|
+
signerAccountId: `hedera:${this.network}:${accountId}`,
|
|
2177
|
+
message
|
|
2178
|
+
};
|
|
2179
|
+
const result = await dAppConnector.signMessage(params);
|
|
2180
|
+
return { userSignature: result.signatureMap };
|
|
2181
|
+
}
|
|
2141
2182
|
saveConnectionInfo(accountId, connectedNetwork) {
|
|
2142
2183
|
if (!accountId) {
|
|
2143
2184
|
localStorage.removeItem("connectedAccountId");
|
|
@@ -2326,6 +2367,9 @@ export {
|
|
|
2326
2367
|
HashgraphSDK,
|
|
2327
2368
|
HashinalsWalletConnectSDK,
|
|
2328
2369
|
Name,
|
|
2329
|
-
Result
|
|
2370
|
+
Result,
|
|
2371
|
+
base64StringToSignatureMap,
|
|
2372
|
+
prefixMessageToSign,
|
|
2373
|
+
verifyMessageSignature
|
|
2330
2374
|
};
|
|
2331
2375
|
//# sourceMappingURL=hashinal-wc.es.js.map
|