@carbonx3/cx3.js 0.3.4 → 0.3.5
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 +6 -6
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/provider.js +4 -3
package/README.md
CHANGED
|
@@ -145,12 +145,12 @@ Supported ABI shapes:
|
|
|
145
145
|
|
|
146
146
|
## Transactions and fees
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
Gas is paid in CX3 to the validator that produces the block: gas used × gas price (devnet default 0.0001 CX3 per gas).
|
|
149
149
|
|
|
150
|
-
- A native transfer uses 21,000 gas: **2.1 CX3**.
|
|
151
|
-
- A contract send or deploy is
|
|
150
|
+
- A native transfer uses 21,000 gas: **2.1 CX3**. The sender needs the amount plus the fee.
|
|
151
|
+
- A contract send or deploy through the gateway is relayed by the chain's own deploy account: the call still runs as your wallet (the chain checks your signature again), and your wallet pays no gas for it. The call's gas limit (100,000 by default) still bounds the work it may do.
|
|
152
152
|
|
|
153
|
-
Too little balance fails with `INSUFFICIENT_BALANCE`, and a gas price below the chain floor with `GAS_PRICE_TOO_LOW`. A send waits for its block by default; with `{ wait: 0 }` it returns at once, and `tx.wait()` polls the transaction status until it is confirmed or failed.
|
|
153
|
+
Too little balance for a native transfer fails with `INSUFFICIENT_BALANCE`, and a gas price below the chain floor with `GAS_PRICE_TOO_LOW`. A send waits for its block by default; with `{ wait: 0 }` it returns at once, and `tx.wait()` polls the transaction status until it is confirmed or failed.
|
|
154
154
|
|
|
155
155
|
## Deploying tokens
|
|
156
156
|
|
|
@@ -233,7 +233,7 @@ try {
|
|
|
233
233
|
| `invalid_client` | The token endpoint refused the application (wrong secret, or revoked) |
|
|
234
234
|
| `insufficient_scope`, `ROUTE_NOT_ALLOWED` | The route needs another scope, or is not open to applications (403) |
|
|
235
235
|
| `RATE_LIMITED` | The application's rate limit was reached (429) |
|
|
236
|
-
| `INSUFFICIENT_BALANCE`, `GAS_PRICE_TOO_LOW` |
|
|
236
|
+
| `INSUFFICIENT_BALANCE`, `GAS_PRICE_TOO_LOW` | A native transfer's sender cannot pay the amount plus gas, or the gas price is below the chain floor |
|
|
237
237
|
| `INVALID_TOKEN_SYMBOL`, `DUPLICATE_TOKEN_SYMBOL` | The symbol is not `A-Z` / `0-9`, or is already in use (409) |
|
|
238
238
|
| `PRIVATE_TOKEN_SENDER`, `PRIVATE_TOKEN_RECIPIENT`, `PRIVATE_TOKEN` | Private token rules (see above) |
|
|
239
239
|
| `TX_FAILED`, `TX_TRACK_TIMEOUT` | The transaction failed, or `tx.wait()` did not see it confirmed in time |
|
|
@@ -258,7 +258,7 @@ Type declarations (`index.d.ts`) ship with the package.
|
|
|
258
258
|
|
|
259
259
|
## Upgrading from 0.2.x
|
|
260
260
|
|
|
261
|
-
Version 0.3.0 signs native transfers for the network's new signing format (0.3.1 to 0.3.4 change only this README, the file headers and comments, not the code)
|
|
261
|
+
Version 0.3.0 signs native transfers for the network's new signing format (0.3.1 to 0.3.4 change only this README, the file headers and comments, not the code). In 0.3.5, `bindApiKey` with a wallet API key asks the gateway's `/wallet/api-key/bind` (before, it asked `/whoami`, which the gateway refuses, so it always failed).
|
|
262
262
|
|
|
263
263
|
- **The genesis hash is signed.** `transferNative` asks the network for its chain id and genesis hash (`provider.getChainIdentity()`) unless both are given as `opts.chainId` and `opts.genesisHash`. 0.2.x transfers no longer verify on the chain.
|
|
264
264
|
- **No fallback chain id.** `buildTransferPayload` throws `NO_CHAIN_IDENTITY` without `chainId` and `genesisHash`; the `CX3_CHAIN_ID` variable and the `chainIdBind` option are gone.
|
package/index.js
CHANGED
|
@@ -33,7 +33,7 @@ const {
|
|
|
33
33
|
} = require("./src/crypto");
|
|
34
34
|
const { normalizeAbi, argsToParams } = require("./src/abi");
|
|
35
35
|
|
|
36
|
-
const VERSION = "0.3.
|
|
36
|
+
const VERSION = "0.3.5";
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Convenience: provider from `options.url` or env `CX3_NODE_URL` — the CX3Api gateway
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbonx3/cx3.js",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Official Node.js SDK (CX3js) for CarbonX3 Green Chain: OAuth2 app access, local secp256k1 signing, ABI-bound contracts and token deploys over REST + JSON",
|
|
5
5
|
"homepage": "https://cx3script.com",
|
|
6
6
|
"publishConfig": {
|
package/src/provider.js
CHANGED
|
@@ -502,7 +502,8 @@ class Cx3Provider {
|
|
|
502
502
|
/**
|
|
503
503
|
* Check that this wallet is the one the credentials belong to (an app and a wallet API key are
|
|
504
504
|
* both bound to one wallet): `{ ok: true }`, or `wallet_mismatch`.
|
|
505
|
-
* OAuth2 app → GET `/wallet/api-key/bind
|
|
505
|
+
* OAuth2 app and cx3wk_ key → GET `/wallet/api-key/bind` (the gateway route; it has no `/whoami`);
|
|
506
|
+
* a cx3wk_ key falls back to `/whoami` on 404 (a same-origin proxy that only forwards that).
|
|
506
507
|
* A development node has no credentials: `{ ok: true, devNode: true }`.
|
|
507
508
|
*/
|
|
508
509
|
async bindApiKey(address) {
|
|
@@ -518,11 +519,11 @@ class Cx3Provider {
|
|
|
518
519
|
return { ok: true, devNode: true };
|
|
519
520
|
}
|
|
520
521
|
try {
|
|
521
|
-
const json = await this.request("/
|
|
522
|
+
const json = await this.request("/wallet/api-key/bind", { query });
|
|
522
523
|
return this._rejectEnvelope(json);
|
|
523
524
|
} catch (e) {
|
|
524
525
|
if (e && e.status === 404) {
|
|
525
|
-
const json = await this.request("/
|
|
526
|
+
const json = await this.request("/whoami", { query });
|
|
526
527
|
return this._rejectEnvelope(json);
|
|
527
528
|
}
|
|
528
529
|
throw e;
|