dash 3.22.0-dev.1 → 3.22.0-dev.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/.mocharc.yml +1 -0
- package/README.md +5 -5
- package/build/src/SDK/Client/Client.js +3 -0
- package/build/src/SDK/Client/Client.js.map +1 -1
- package/build/src/SDK/Client/Client.spec.js +3 -3
- package/build/src/SDK/Client/Client.spec.js.map +1 -1
- package/build/src/SDK/Client/Platform/Platform.js +4 -2
- package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
- package/build/src/SDK/Client/Platform/createAssetLockTransaction.js +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/{broadcast.js → publish.js} +6 -6
- package/build/src/SDK/Client/Platform/methods/contracts/publish.js.map +1 -0
- package/build/src/SDK/Client/Platform/methods/contracts/update.js +75 -0
- package/build/src/SDK/Client/Platform/methods/contracts/update.js.map +1 -0
- package/build/src/SDK/Client/Platform/methods/documents/get.js +2 -5
- package/build/src/SDK/Client/Platform/methods/documents/get.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +9 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/names/register.js +1 -1
- package/build/src/SDK/Client/Platform/methods/names/register.js.map +1 -1
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js +2 -0
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js.map +1 -1
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js +5 -2
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js.map +1 -1
- package/build/src/utils/createFakeIntantLock.js +2 -0
- package/build/src/utils/createFakeIntantLock.js.map +1 -1
- package/build/tests/fixtures/contracts.json +3 -1
- package/dist/src/SDK/Client/Platform/Platform.d.ts +7 -1
- package/dist/src/SDK/Client/Platform/createAssetLockTransaction.d.ts +1 -1
- package/dist/src/SDK/Client/Platform/methods/contracts/publish.d.ts +10 -0
- package/dist/src/SDK/Client/Platform/methods/contracts/update.d.ts +10 -0
- package/dist/src/SDK/SDK.d.ts +167 -4
- package/docs/README.md +6 -6
- package/docs/_sidebar.md +19 -17
- package/docs/examples/pay-to-another-address.md +1 -1
- package/docs/examples/publishing-a-new-contract.md +7 -7
- package/docs/examples/receive-money-and-check-balance.md +2 -2
- package/docs/examples/sign-and-verify-messages.md +1 -1
- package/docs/examples/updating-a-contract.md +55 -0
- package/docs/getting-started/core-concepts.md +2 -2
- package/docs/getting-started/dash-platform-applications.md +1 -1
- package/docs/getting-started/quickstart.md +1 -1
- package/docs/platform/contracts/about-contracts.md +1 -1
- package/docs/platform/contracts/create.md +2 -2
- package/docs/platform/contracts/{broadcast.md → publish.md} +8 -8
- package/docs/platform/contracts/update.md +14 -0
- package/docs/platform/documents/broadcast.md +4 -4
- package/docs/platform/documents/create.md +2 -2
- package/docs/platform/identities/about-identity.md +1 -1
- package/docs/platform/identities/register.md +1 -1
- package/docs/platform/identities/topUp.md +1 -1
- package/docs/platform/names/register.md +1 -1
- package/docs/wallet/about-wallet-lib.md +1 -1
- package/examples/node/register-contract.js +1 -1
- package/examples/schema.json +2 -0
- package/karma.conf.js +17 -8
- package/package.json +32 -23
- package/src/SDK/Client/Client.spec.ts +3 -3
- package/src/SDK/Client/Client.ts +3 -0
- package/src/SDK/Client/Platform/Platform.ts +12 -3
- package/src/SDK/Client/Platform/createAssetLockTransaction.ts +1 -1
- package/src/SDK/Client/Platform/methods/contracts/{broadcast.ts → publish.ts} +4 -4
- package/src/SDK/Client/Platform/methods/contracts/update.ts +26 -0
- package/src/SDK/Client/Platform/methods/documents/get.ts +1 -4
- package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +6 -1
- package/src/SDK/Client/Platform/methods/names/register.ts +1 -1
- package/src/test/fixtures/createIdentityFixtureInAccount.ts +3 -1
- package/src/test/mocks/createAndAttachTransportMocksToClient.ts +25 -21
- package/src/utils/createFakeIntantLock.ts +2 -0
- package/tests/fixtures/contracts.json +3 -1
- package/tests/fixtures/dp1.schema.json +2 -0
- package/tests/fixtures/ratePlatform.schema.json +1 -0
- package/webpack.base.config.js +5 -2
- package/webpack.config.js +3 -24
- package/.editorconfig +0 -2
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -27
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -32
- package/.github/workflows/.env +0 -5
- package/.github/workflows/test_and_release.yml +0 -170
- package/build/src/SDK/Client/Platform/methods/contracts/broadcast.js.map +0 -1
- package/dist/dash.min.js +0 -8
- package/dist/dash.min.js.LICENSE.txt +0 -47
- package/dist/src/SDK/Client/Platform/methods/contracts/broadcast.d.ts +0 -10
package/dist/src/SDK/SDK.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { Client as _Client } from './Client';
|
|
2
3
|
import { Platform as _Platform } from './Platform';
|
|
3
4
|
import { Wallet as _Wallet, Account as _Account, KeyChain as _KeyChain } from '@dashevo/wallet-lib';
|
|
@@ -10,10 +11,172 @@ export declare namespace SDK {
|
|
|
10
11
|
let Account: typeof _Account;
|
|
11
12
|
let KeyChain: typeof _KeyChain;
|
|
12
13
|
let WalletLib: {
|
|
13
|
-
CONSTANTS:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
CONSTANTS: {
|
|
15
|
+
BIP45: string;
|
|
16
|
+
BIP44: string;
|
|
17
|
+
DUFFS_PER_DASH: number;
|
|
18
|
+
BIP44_ADDRESS_GAP: number;
|
|
19
|
+
SECURE_TRANSACTION_CONFIRMATIONS_NB: number;
|
|
20
|
+
BIP32__ROOT_PATH: string;
|
|
21
|
+
BIP44_LIVENET_ROOT_PATH: string;
|
|
22
|
+
BIP44_TESTNET_ROOT_PATH: string;
|
|
23
|
+
DIP9_LIVENET_ROOT_PATH: string;
|
|
24
|
+
DIP9_TESTNET_ROOT_PATH: string;
|
|
25
|
+
UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR: number;
|
|
26
|
+
UTXO_SELECTION_MIN_TX_AMOUNT_VS_UTXO_FACTOR: number;
|
|
27
|
+
UTXO_SELECTION_MAX_FEE_VS_TX_AMOUNT_FACTOR: number;
|
|
28
|
+
UTXO_SELECTION_MAX_FEE_VS_SINGLE_UTXO_FEE_FACTOR: number;
|
|
29
|
+
MAX_STANDARD_TX_SIZE: number;
|
|
30
|
+
MAX_P2SH_SIGOPS: number;
|
|
31
|
+
COINBASE_MATURITY: number;
|
|
32
|
+
UTXO_CHAINED_SPENDING_LIMIT_FOR_TX: number;
|
|
33
|
+
FEES: {
|
|
34
|
+
DUST_RELAY_TX_FEE: number;
|
|
35
|
+
ZERO: number;
|
|
36
|
+
ECONOMIC: number;
|
|
37
|
+
NORMAL: number;
|
|
38
|
+
PRIORITY: number;
|
|
39
|
+
INSTANT_FEE_PER_INPUTS: number;
|
|
40
|
+
};
|
|
41
|
+
UNCONFIRMED_TRANSACTION_STATUS_CODE: number;
|
|
42
|
+
WALLET_TYPES: {
|
|
43
|
+
ADDRESS: string;
|
|
44
|
+
PUBLICKEY: string;
|
|
45
|
+
PRIVATEKEY: string;
|
|
46
|
+
SINGLE_ADDRESS: string;
|
|
47
|
+
HDWALLET: string;
|
|
48
|
+
HDPUBLIC: string;
|
|
49
|
+
};
|
|
50
|
+
INJECTION_LISTS: {
|
|
51
|
+
SAFE_FUNCTIONS: string[];
|
|
52
|
+
UNSAFE_FUNCTIONS: string[];
|
|
53
|
+
UNSAFE_PROPERTIES: string[];
|
|
54
|
+
SAFE_PROPERTIES: string[];
|
|
55
|
+
};
|
|
56
|
+
TRANSACTION_HISTORY_TYPES: {
|
|
57
|
+
RECEIVED: string;
|
|
58
|
+
SENT: string;
|
|
59
|
+
ADDRESS_TRANSFER: string;
|
|
60
|
+
ACCOUNT_TRANSFER: string;
|
|
61
|
+
UNKNOWN: string;
|
|
62
|
+
};
|
|
63
|
+
STORAGE: {
|
|
64
|
+
autosaveIntervalTime: number;
|
|
65
|
+
};
|
|
66
|
+
TXIN_OUTPOINT_TXID_BYTES: number;
|
|
67
|
+
TXIN_OUTPOINT_INDEX_BYTES: number;
|
|
68
|
+
TXIN_SEQUENCE_BYTES: number;
|
|
69
|
+
TXOUT_DUFFS_VALUE_BYTES: number;
|
|
70
|
+
VERSION_BYTES: number;
|
|
71
|
+
N_LOCKTIME_BYTES: number;
|
|
72
|
+
BLOOM_FALSE_POSITIVE_RATE: number;
|
|
73
|
+
NULL_HASH: string;
|
|
74
|
+
};
|
|
75
|
+
EVENTS: {
|
|
76
|
+
PREFETCHED: string;
|
|
77
|
+
CREATED: string;
|
|
78
|
+
STARTED: string;
|
|
79
|
+
READY: string;
|
|
80
|
+
CONFIRMED_BALANCE_CHANGED: string;
|
|
81
|
+
UNCONFIRMED_BALANCE_CHANGED: string;
|
|
82
|
+
BLOCKHEIGHT_CHANGED: string;
|
|
83
|
+
BLOCK: string;
|
|
84
|
+
TRANSACTION: string;
|
|
85
|
+
BLOCKHEADER: string;
|
|
86
|
+
FETCHED_ADDRESS: string;
|
|
87
|
+
ERROR_UPDATE_ADDRESS: string;
|
|
88
|
+
FETCHED_TRANSACTION: string;
|
|
89
|
+
FETCHED_UNCONFIRMED_TRANSACTION: string;
|
|
90
|
+
FETCHED_CONFIRMED_TRANSACTION: string;
|
|
91
|
+
GENERATED_ADDRESS: string;
|
|
92
|
+
DISCOVERY_STARTED: string;
|
|
93
|
+
CONFIGURED: string;
|
|
94
|
+
INITIALIZED: string;
|
|
95
|
+
SAVE_STATE_FAILED: string;
|
|
96
|
+
SAVE_STATE_SUCCESS: string;
|
|
97
|
+
REHYDRATE_STATE_FAILED: string;
|
|
98
|
+
REHYDRATE_STATE_SUCCESS: string;
|
|
99
|
+
INSTANT_LOCK: string;
|
|
100
|
+
};
|
|
101
|
+
plugins: {
|
|
102
|
+
StandardPlugin: typeof import("@dashevo/wallet-libsrc/plugins/StandardPlugin");
|
|
103
|
+
Worker: typeof import("@dashevo/wallet-libsrc/plugins/Worker");
|
|
104
|
+
};
|
|
105
|
+
utils: {
|
|
106
|
+
extendTransactionsWithMetadata: (transactions: any, transactionsMetadata: any) => any[];
|
|
107
|
+
varIntSizeBytesFromLength: (length: any) => number;
|
|
108
|
+
calculateTransactionFees: typeof import("@dashevo/wallet-libsrc/utils/calculateTransactionFees");
|
|
109
|
+
categorizeTransactions: typeof import("@dashevo/wallet-libsrc/utils/categorizeTransactions");
|
|
110
|
+
mnemonicToHDPrivateKey: (mnemonic: any, network?: any, passphrase?: string) => any;
|
|
111
|
+
generateNewMnemonic: () => any;
|
|
112
|
+
seedToHDPrivateKey: (seed: any, network?: string) => any;
|
|
113
|
+
mnemonicToWalletId: (mnemonic: any) => string;
|
|
114
|
+
filterTransactions: typeof import("@dashevo/wallet-libsrc/utils/filterTransactions");
|
|
115
|
+
classifyAddresses: typeof import("@dashevo/wallet-libsrc/utils/classifyAddresses");
|
|
116
|
+
mnemonicToSeed: (mnemonic: any, password?: string) => any;
|
|
117
|
+
feeCalculation: (type?: string) => {
|
|
118
|
+
type: null;
|
|
119
|
+
value: null;
|
|
120
|
+
};
|
|
121
|
+
coinSelection: (utxosList: any, outputsList: any, deductFee?: boolean, feeCategory?: string, strategy?: (utxosList: any, outputsList: any, deductFee?: any, feeCategory?: any) => {
|
|
122
|
+
utxos: never[];
|
|
123
|
+
outputs: never[];
|
|
124
|
+
feeCategory: any;
|
|
125
|
+
estimatedFee: number;
|
|
126
|
+
utxosValue: number;
|
|
127
|
+
}) => {
|
|
128
|
+
utxos: never[];
|
|
129
|
+
outputs: never[];
|
|
130
|
+
feeCategory: any;
|
|
131
|
+
estimatedFee: number;
|
|
132
|
+
utxosValue: number;
|
|
133
|
+
};
|
|
134
|
+
doubleSha256: (data: any) => Buffer;
|
|
135
|
+
dashToDuffs: typeof import("@dashevo/wallet-libsrc/utils/dashToDuffs");
|
|
136
|
+
duffsToDash: typeof import("@dashevo/wallet-libsrc/utils/duffsToDash");
|
|
137
|
+
fundWallet: typeof import("@dashevo/wallet-libsrc/utils/fundWallet");
|
|
138
|
+
getBytesOf: typeof import("@dashevo/wallet-libsrc/utils/getBytesOf");
|
|
139
|
+
hasMethod: typeof import("@dashevo/wallet-libsrc/utils/hasMethod");
|
|
140
|
+
hasProp: typeof import("@dashevo/wallet-libsrc/utils/hasProp");
|
|
141
|
+
sha256: (data: any) => Buffer;
|
|
142
|
+
hash: (alg: any, data: any) => Buffer;
|
|
143
|
+
is: {
|
|
144
|
+
arr: (arr: any) => boolean;
|
|
145
|
+
num: (num: any) => boolean;
|
|
146
|
+
float: (float: any) => boolean;
|
|
147
|
+
int: (int: any) => boolean;
|
|
148
|
+
hex: (h: any) => boolean;
|
|
149
|
+
string: (str: any) => boolean;
|
|
150
|
+
bool: (b: any) => boolean;
|
|
151
|
+
obj: (obj: any) => boolean;
|
|
152
|
+
fn: (fn: any) => boolean;
|
|
153
|
+
type(val: any, type: any): boolean;
|
|
154
|
+
def: (val: any) => boolean;
|
|
155
|
+
undef: (val: any) => boolean;
|
|
156
|
+
null: (val: any) => boolean;
|
|
157
|
+
exist: (val: any) => boolean;
|
|
158
|
+
undefOrNull: (val: any) => boolean;
|
|
159
|
+
promise: (fn: any) => boolean;
|
|
160
|
+
JSON(val: any): boolean;
|
|
161
|
+
stringified(val: any): boolean;
|
|
162
|
+
mnemonic: (mnemonic: any) => boolean;
|
|
163
|
+
network: (network: any) => boolean;
|
|
164
|
+
publicKey: (pKey: any) => any;
|
|
165
|
+
privateKey: (pKey: any) => any;
|
|
166
|
+
HDPrivateKey: (hdKey: any) => any;
|
|
167
|
+
HDPublicKey: (hdKey: any) => any;
|
|
168
|
+
seed: (seed: any) => boolean;
|
|
169
|
+
address: (addr: any) => boolean;
|
|
170
|
+
addressObj: (addrObj: any) => boolean;
|
|
171
|
+
transactionObj: (tx: any) => boolean;
|
|
172
|
+
dashcoreTransaction: (tx: any) => boolean;
|
|
173
|
+
feeRate: (feeRate: any) => boolean;
|
|
174
|
+
txid: (txid: any) => boolean;
|
|
175
|
+
utxo: (utxo: any) => boolean;
|
|
176
|
+
output: (output: any) => boolean;
|
|
177
|
+
rawtx: (rawtx: any) => boolean;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
17
180
|
};
|
|
18
181
|
}
|
|
19
182
|
export { SDK as default };
|
package/docs/README.md
CHANGED
|
@@ -65,12 +65,12 @@ client.getWalletAccount().then(async (account) => {
|
|
|
65
65
|
|
|
66
66
|
### Use-cases examples
|
|
67
67
|
|
|
68
|
-
- [Generate a mnemonic](
|
|
69
|
-
- [Receive money and display balance](
|
|
70
|
-
- [Pay to another address](
|
|
71
|
-
- [Use a local evonet](
|
|
72
|
-
- [Publishing a new contract](
|
|
73
|
-
- [Use another BIP44 account](
|
|
68
|
+
- [Generate a mnemonic](examples/generate-a-new-mnemonic.md)
|
|
69
|
+
- [Receive money and display balance](examples/receive-money-and-check-balance.md)
|
|
70
|
+
- [Pay to another address](examples/pay-to-another-address.md)
|
|
71
|
+
- [Use a local evonet](examples/use-local-evonet.md)
|
|
72
|
+
- [Publishing a new contract](examples/publishing-a-new-contract.md)
|
|
73
|
+
- [Use another BIP44 account](examples/use-different-account.md)
|
|
74
74
|
|
|
75
75
|
### Tutorial
|
|
76
76
|
|
package/docs/_sidebar.md
CHANGED
|
@@ -5,32 +5,33 @@
|
|
|
5
5
|
- [Dash Platform Applications](getting-started/dash-platform-applications.md)
|
|
6
6
|
- [About Schemas](getting-started/about-schemas.md)
|
|
7
7
|
- [With TypeScript](getting-started/with-typescript.md)
|
|
8
|
-
|
|
9
|
-
- Examples
|
|
10
|
-
- [Generate a mnemonic](/examples/generate-a-new-mnemonic.md)
|
|
11
|
-
- [Receive money and display balance](/examples/receive-money-and-check-balance.md)
|
|
12
|
-
- [Pay to another address](/examples/pay-to-another-address.md)
|
|
13
|
-
- [Use a local evonet](/examples/use-local-evonet.md)
|
|
14
|
-
- [Fetch an identity from its name](/examples/fetch-an-identity-from-its-name.md)
|
|
15
|
-
- [Publishing
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
18
|
-
|
|
8
|
+
|
|
9
|
+
- Examples
|
|
10
|
+
- [Generate a mnemonic](/examples/generate-a-new-mnemonic.md)
|
|
11
|
+
- [Receive money and display balance](/examples/receive-money-and-check-balance.md)
|
|
12
|
+
- [Pay to another address](/examples/pay-to-another-address.md)
|
|
13
|
+
- [Use a local evonet](/examples/use-local-evonet.md)
|
|
14
|
+
- [Fetch an identity from its name](/examples/fetch-an-identity-from-its-name.md)
|
|
15
|
+
- [Publishing new contract](/examples/publishing-a-new-contract.md)
|
|
16
|
+
- [Updating an existing contract](/examples/updating-a-contract.md)
|
|
17
|
+
- [Use another BIP44 account](/examples/use-different-account.md)
|
|
18
|
+
- [Sign and verify messages](/examples/sign-and-verify-messages.md)
|
|
19
|
+
|
|
19
20
|
- Tutorial
|
|
20
21
|
- [Register an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
|
|
21
22
|
- [Register a Name for an Identity](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity)
|
|
22
23
|
|
|
23
|
-
- Snippets
|
|
24
|
+
- Snippets
|
|
24
25
|
- [Create and fund wallet](https://github.com/dashevo/DashJS/tree/master/examples/node/create-and-fund-wallet.js)
|
|
25
26
|
- [Register identity](https://github.com/dashevo/DashJS/tree/master/examples/node/register-identity.js)
|
|
26
27
|
- [Register name](https://github.com/dashevo/DashJS/tree/master/examples/node/register-name.js)
|
|
27
28
|
- [Retrieve Contract](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-contract.js)
|
|
28
29
|
- [Retrieve Documents](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-documents.js)
|
|
29
30
|
- [Retrieve Identity](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-identity.js)
|
|
30
|
-
- [Retrieve Name](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-name.js)
|
|
31
|
-
|
|
32
|
-
- Usage
|
|
33
|
-
- [DAPI](usage/dapi.md)
|
|
31
|
+
- [Retrieve Name](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-name.js)
|
|
32
|
+
|
|
33
|
+
- Usage
|
|
34
|
+
- [DAPI](usage/dapi.md)
|
|
34
35
|
- [Platform](platform/about-platform.md)
|
|
35
36
|
- [About platform](platform/about-platform.md)
|
|
36
37
|
- **Identities**
|
|
@@ -42,7 +43,8 @@
|
|
|
42
43
|
- [About contracts](platform/contracts/about-contracts.md)
|
|
43
44
|
- [`.get()`](platform/contracts/get.md)
|
|
44
45
|
- [`.create()`](platform/contracts/create.md)
|
|
45
|
-
- [`.
|
|
46
|
+
- [`.publish()`](platform/contracts/publish.md)
|
|
47
|
+
- [`.update()`](platform/contracts/update.md)
|
|
46
48
|
- **Documents**
|
|
47
49
|
- [About documents](platform/documents/about-documents.md)
|
|
48
50
|
- [`.get()`](platform/documents/get.md)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Paying to another address
|
|
2
2
|
|
|
3
|
-
In order to pay, you need to have an [existing balance](
|
|
3
|
+
In order to pay, you need to have an [existing balance](../examples/receive-money-and-check-balance.md).
|
|
4
4
|
The below code will allow you to pay to a single address a specific amount of satoshis.
|
|
5
5
|
|
|
6
6
|
```js
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Right now, Evonet does not support publishing a public contract. You will have to run a local instance or wait for updates to the [Dash Platform documentation](https://dashplatform.readme.io/docs) regarding how to run a devnet locally and publish a contract.
|
|
4
4
|
|
|
5
|
-
For now you can try your luck using the [Dash Network Deploy tool](https://github.com/dashevo/dash-network-deploy) and refer to [how to use a local evonet](
|
|
5
|
+
For now you can try your luck using the [Dash Network Deploy tool](https://github.com/dashevo/dash-network-deploy) and refer to [how to use a local evonet](../examples/use-local-evonet.md).
|
|
6
6
|
|
|
7
|
-
## Create your contract
|
|
7
|
+
## Create your contract
|
|
8
8
|
|
|
9
|
-
After having [registered an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
|
|
10
|
-
and [attached to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity) crafted your schema (you can see how on [about schemas](getting-started/about-schemas.md) and read the [DPNS schema](https://github.com/dashevo/dpns-contract/blob/v0.2-dev/src/schema/dpns-documents.json) as an example), you then can perform the below actions :
|
|
9
|
+
After having [registered an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
|
|
10
|
+
and [attached to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity) crafted your schema (you can see how on [about schemas](getting-started/about-schemas.md) and read the [DPNS schema](https://github.com/dashevo/dpns-contract/blob/v0.2-dev/src/schema/dpns-documents.json) as an example), you then can perform the below actions :
|
|
11
11
|
|
|
12
12
|
```js
|
|
13
13
|
const schema = {};// You JSON schema defining the app.
|
|
@@ -31,11 +31,11 @@ async function registerContract() {
|
|
|
31
31
|
const {platform} = client;
|
|
32
32
|
const identity = await getIdentity(appName);
|
|
33
33
|
const contract = platform.contracts.create(schema, identity)
|
|
34
|
-
const contractId = await platform.contracts.
|
|
34
|
+
const contractId = await platform.contracts.publish(contract, identity);
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
## Fetch or publish documents on your app
|
|
38
|
+
## Fetch or publish documents on your app
|
|
39
39
|
|
|
40
40
|
```js
|
|
41
41
|
const schema = {};// You JSON schema defining the app.
|
|
@@ -47,7 +47,7 @@ const client = new Dash.Client({
|
|
|
47
47
|
},
|
|
48
48
|
apps:{
|
|
49
49
|
myapp:{
|
|
50
|
-
contractId:""// The registered contract id
|
|
50
|
+
contractId:""// The registered contract id
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Receive money and display balance
|
|
2
2
|
|
|
3
|
-
Initialize the SDK Client with your [generated mnemonic](
|
|
3
|
+
Initialize the SDK Client with your [generated mnemonic](../examples/generate-a-new-mnemonic.md) passed as an option.
|
|
4
4
|
By default, the SDK Client will work on Evonet, the only network having DAPI at the time of writing.
|
|
5
5
|
|
|
6
6
|
```js
|
|
@@ -13,7 +13,7 @@ const client = new Dash.Client({
|
|
|
13
13
|
|
|
14
14
|
Having set up your `client` instance, you be able to access the `account` and `wallet` instance generated from your mnemonic.
|
|
15
15
|
|
|
16
|
-
You can read more on [how to use a different account](
|
|
16
|
+
You can read more on [how to use a different account](../examples/use-different-account.md) as by default, you are on the first BIP44 account.
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
## Generate a receiving address
|
|
@@ -11,4 +11,4 @@ const signed = account.sign(message, pk);
|
|
|
11
11
|
const verify = message.verify(pk.toAddress().toString(), signed.toString());
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
See [code snippet](https://github.com/dashevo/
|
|
14
|
+
See [code snippet](https://github.com/dashevo/platform/blob/master/packages/js-dash-sdk/examples/node/sign-and-verify-messages.js).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
## Updating an existing contract
|
|
2
|
+
|
|
3
|
+
To update your existing data contract you have to follow these steps:
|
|
4
|
+
|
|
5
|
+
### Fetch your exising contract
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
const schema = {};// You JSON schema defining the app.
|
|
9
|
+
const client = new Dash.Client({
|
|
10
|
+
wallet: {
|
|
11
|
+
mnemonic: '', // Your app mnemonic, which holds the identity
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const exisingContractId = ''; // Your existing data contract id
|
|
16
|
+
|
|
17
|
+
const existingDataContract = await client.platform.contracts.get(exisingContractId);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Update document definitions
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
// Update an existing document
|
|
24
|
+
const documentDefinition = existingDataContract.getDocumentDefinition('myDocumentType');
|
|
25
|
+
|
|
26
|
+
// adding optional field
|
|
27
|
+
documentDefinition.properties.newField = {
|
|
28
|
+
type: 'integer',
|
|
29
|
+
minimum: 1,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
existingDataContract.setDocumentDefinition('myDocumentType', documentDefinition);
|
|
33
|
+
|
|
34
|
+
// ... or, add a new one
|
|
35
|
+
const newDocumentDefinition = {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
someField: {
|
|
39
|
+
type: 'integer',
|
|
40
|
+
minimum: 42,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ['someField'],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
existingDataContract.setDocumentDefinition('myNewDocument', newDocumentDefinition);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Broadcast your changes
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
await client.platform.contracts.update(existingDataContract, yourExistingIdentity);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Note, that update will be only allowed if schema is backward compatible. Also, version incremented by 1 and only one of following fields updated: `$defs`, `documents` or `version`**
|
|
@@ -16,7 +16,7 @@ Since the introduction of deterministic wallets ([BIP44](https://github.com/bitc
|
|
|
16
16
|
|
|
17
17
|
It is the instance you will use most of the time for receiving or broadcasting payments.
|
|
18
18
|
|
|
19
|
-
You can access your account with `client.getWalletAccount()` and see [how to use a different account](
|
|
19
|
+
You can access your account with `client.getWalletAccount()` and see [how to use a different account](../examples/use-different-account.md) if you need to get a specific account index.
|
|
20
20
|
|
|
21
21
|
## App Schema and Contracts
|
|
22
22
|
|
|
@@ -25,4 +25,4 @@ The Dash Platform Chain, provides to developers the ability to create applicatio
|
|
|
25
25
|
When registered, those applications schemas are called contracts and contains a contractId (namespace : `client.platform.contracts`).
|
|
26
26
|
By default, this library supports Dash Platform Name Service (DPNS) (to attach a name to an identity), under the namespace `client.platform.names` for testnet.
|
|
27
27
|
|
|
28
|
-
You can read more on [how to use DPNS on a local Evonet devnet](
|
|
28
|
+
You can read more on [how to use DPNS on a local Evonet devnet](../examples/use-local-evonet.md) or [how to use multiple apps](../getting-started/multiple-apps.md).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## DPNS
|
|
2
2
|
|
|
3
|
-
DPNS is handled in the Dash SDK Client under the namespace `client.platform.names.*'`. [Read more here](
|
|
3
|
+
DPNS is handled in the Dash SDK Client under the namespace `client.platform.names.*'`. [Read more here](../platform/names/about-dpns.md)
|
|
4
4
|
|
|
5
5
|
## DashPay
|
|
6
6
|
|
|
@@ -50,7 +50,7 @@ client.getWalletAccount().then(async (account) => {
|
|
|
50
50
|
|
|
51
51
|
## Read a document
|
|
52
52
|
|
|
53
|
-
At the time of writing, you will need to have registered a data contract yourself. See [publishing a new contract](
|
|
53
|
+
At the time of writing, you will need to have registered a data contract yourself. See [publishing a new contract](../examples/publishing-a-new-contract.md).
|
|
54
54
|
|
|
55
55
|
```js
|
|
56
56
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## What is a contract
|
|
2
2
|
|
|
3
|
-
Contracts are a [registered](
|
|
3
|
+
Contracts are a [registered](../../examples/publishing-a-new-contract.md) set of rules defined in a [JSON Application Schema](../../getting-started/core-concepts#schemas).
|
|
4
4
|
|
|
5
5
|
See more on the Dash Platform documentation about [Data Contract](https://dashplatform.readme.io/docs/explanation-platform-protocol-data-contract).
|
|
6
6
|
|
|
@@ -6,7 +6,7 @@ Parameters:
|
|
|
6
6
|
| parameters | type | required | Description |
|
|
7
7
|
|--------------------------|-------------------|------------------ | ----------------------------------------------------------------- |
|
|
8
8
|
| **contractDefinitions** | JSONDataContract | yes | The defined [JSON Application Schema](https://dashplatform.readme.io/docs/explanation-platform-protocol-data-contract) |
|
|
9
|
-
| **identity** | Identity | yes | A valid [registered `application` identity](
|
|
9
|
+
| **identity** | Identity | yes | A valid [registered `application` identity](../identities/register.md) |
|
|
10
10
|
|
|
11
11
|
**Example**:
|
|
12
12
|
|
|
@@ -31,6 +31,6 @@ Parameters:
|
|
|
31
31
|
const validationResult = client.platform.dpp.dataContract.validate(contract);
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
**Note**: When your contract is created, it will only exist locally, use the [broadcast](
|
|
34
|
+
**Note**: When your contract is created, it will only exist locally, use the [broadcast](../contracts/broadcast.md) method to register it.
|
|
35
35
|
|
|
36
36
|
Returns : Contract.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
**Usage**: `client.platform.contracts.
|
|
2
|
-
**Description**: This method will sign and broadcast any valid contract.
|
|
1
|
+
**Usage**: `client.platform.contracts.publish(contract, identity)`
|
|
2
|
+
**Description**: This method will sign and broadcast any valid contract.
|
|
3
3
|
|
|
4
|
-
Parameters:
|
|
4
|
+
Parameters:
|
|
5
5
|
|
|
6
|
-
| parameters | type | required | Description |
|
|
6
|
+
| parameters | type | required | Description |
|
|
7
7
|
|---------------------------|-----------|----------------| ------------------------------------------------------------------------------|
|
|
8
|
-
| **contract** | Contract | yes | A valid [created contract](
|
|
9
|
-
| **identity** | Identity | yes | A valid [registered `application` identity](
|
|
8
|
+
| **contract** | Contract | yes | A valid [created contract](../contracts/create.md) |
|
|
9
|
+
| **identity** | Identity | yes | A valid [registered `application` identity](../identities/register.md) |
|
|
10
10
|
|
|
11
11
|
**Example**:
|
|
12
12
|
```js
|
|
@@ -14,7 +14,7 @@ const identityId = '';// Your identity identifier.
|
|
|
14
14
|
const identity = await client.platform.identities.get(identityId);
|
|
15
15
|
// See the contract.create documentation for more on how to create a dataContract
|
|
16
16
|
const contract = await client.platform.contracts.create(contractDefinitions, identity);
|
|
17
|
-
await platform.contracts.
|
|
17
|
+
await platform.contracts.publish(contract, identity);
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Returns :
|
|
20
|
+
Returns : DataContractCreateTransition.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
**Usage**: `client.platform.contracts.update(contract, identity)`
|
|
2
|
+
**Description**: This method will sign and broadcast an updated valid contract.
|
|
3
|
+
|
|
4
|
+
Parameters:
|
|
5
|
+
|
|
6
|
+
| parameters | type | required | Description |
|
|
7
|
+
|---------------------------|-----------|----------------| ------------------------------------------------------------------------------|
|
|
8
|
+
| **contract** | Contract | yes | A valid [created contract](/platform/contracts/create.md) |
|
|
9
|
+
| **identity** | Identity | yes | A valid [registered `application` identity](/platform/identities/register.md) |
|
|
10
|
+
|
|
11
|
+
**Example**:
|
|
12
|
+
You may check [following document](/examples/updating-a-contract.md) for an example on how to update a contract.
|
|
13
|
+
|
|
14
|
+
Returns : DataContractUpdateTransition.
|
|
@@ -6,10 +6,10 @@ Parameters:
|
|
|
6
6
|
| parameters | type | required | Description |
|
|
7
7
|
|----------------------------|------------|----------| ----------------------------------------------------------------------------|
|
|
8
8
|
| **documents** | Object | yes | |
|
|
9
|
-
| **documents.create** | Document[] | no | array of valid [created document](
|
|
10
|
-
| **documents.replace** | Document[] | no | array of valid [created document](
|
|
11
|
-
| **documents.delete** | Document[] | no | array of valid [created document](
|
|
12
|
-
| **identity** | Identity | yes | A valid [registered identity](
|
|
9
|
+
| **documents.create** | Document[] | no | array of valid [created document](../documents/create.md) to create |
|
|
10
|
+
| **documents.replace** | Document[] | no | array of valid [created document](../documents/create.md) to replace |
|
|
11
|
+
| **documents.delete** | Document[] | no | array of valid [created document](../documents/create.md) to delete |
|
|
12
|
+
| **identity** | Identity | yes | A valid [registered identity](../identities/register.md) |
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
**Example**:
|
|
@@ -6,7 +6,7 @@ Parameters:
|
|
|
6
6
|
| parameters | type | required | Description |
|
|
7
7
|
|-------------------|---------|------------------ | ----------------------------------------------------------------- |
|
|
8
8
|
| **dotLocator** | string | yes | Field of a specific application, under the form `appName.fieldName` |
|
|
9
|
-
| **identity** | Identity| yes | A valid [registered identity](
|
|
9
|
+
| **identity** | Identity| yes | A valid [registered identity](../identities/register.md) |
|
|
10
10
|
| **docOpts** | Object | yes | A valid data that match the data contract structure |
|
|
11
11
|
|
|
12
12
|
**Example**:
|
|
@@ -21,6 +21,6 @@ const helloWorldDocument = await platform.documents.create(
|
|
|
21
21
|
{ message: 'Hello World'},
|
|
22
22
|
);
|
|
23
23
|
```
|
|
24
|
-
**Note**: When your document is created, it will only exist locally, use the [broadcast](
|
|
24
|
+
**Note**: When your document is created, it will only exist locally, use the [broadcast](../documents/broadcast.md) method to register it.
|
|
25
25
|
|
|
26
26
|
Returns: Document
|
|
@@ -4,7 +4,7 @@ An Identity is a blockchain-based identifier for individuals (users) and applica
|
|
|
4
4
|
Identity is the atomic element that linked with additional applications can be extended to provide new functionality.
|
|
5
5
|
|
|
6
6
|
Read more on the Dash Platform documentation about [Identity](https://dashplatform.readme.io/docs/explanation-identity).
|
|
7
|
-
You might also want to consult the usage for the [DPNS Name Service](/
|
|
7
|
+
You might also want to consult the usage for the [DPNS Name Service](../names/about-dpns.md) in order to attach a name to your created identity.
|
|
8
8
|
|
|
9
9
|
## Credits
|
|
10
10
|
|
|
@@ -9,6 +9,6 @@ Parameters:
|
|
|
9
9
|
|
|
10
10
|
**Example**: `await client.platform.identities.register()`
|
|
11
11
|
|
|
12
|
-
**Note**: The created identity will be associated to the active account. You might want to know more about how to [change your active account](
|
|
12
|
+
**Note**: The created identity will be associated to the active account. You might want to know more about how to [change your active account](../../examples/use-different-account.md).
|
|
13
13
|
|
|
14
14
|
Returns : Identity.
|
|
@@ -5,7 +5,7 @@ Parameters:
|
|
|
5
5
|
|
|
6
6
|
| parameters | type | required | Description |
|
|
7
7
|
|-------------------|---------|------------------| ----------------------------------------------------------------------------------------|
|
|
8
|
-
| **identity** | Identity| yes | A valid [registered identity](
|
|
8
|
+
| **identity** | Identity| yes | A valid [registered identity](../identities/register.md) |
|
|
9
9
|
| **amount** | number | yes | A duffs (satoshis) value corresponding to the amount you want to top up to the identity.|
|
|
10
10
|
|
|
11
11
|
**Example**:
|
|
@@ -9,7 +9,7 @@ Parameters:
|
|
|
9
9
|
| **records** | Object | yes | records object having only one of the following items |
|
|
10
10
|
| **records.dashUniqueIdentityId** | String | no | Unique Identity ID for this name record |
|
|
11
11
|
| **records.dashAliasIdentityId** | String | no | Used to signify that this name is the alias for another id |
|
|
12
|
-
| **identity** | Identity | yes | A valid [registered identity](
|
|
12
|
+
| **identity** | Identity | yes | A valid [registered identity](../identities/register.md) |
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
**Example**: `await client.platform.identities.register('alice', { dashUniqueIdentityId: identity.getId() }, identity)`
|
|
@@ -4,4 +4,4 @@ When Dash.Client is initiated with a `mnemonic` property, a wallet instance is a
|
|
|
4
4
|
|
|
5
5
|
In order to ensure the sync-up with the network has happened, you will need to wait for the method `client.isReady()` to resolve.
|
|
6
6
|
|
|
7
|
-
You will find else where the [complete documentation of Wallet-lib](https://github.com/dashevo/wallet-lib), as we only cover the most basic pieces in this documentation.
|
|
7
|
+
You will find else where the [complete documentation of Wallet-lib](https://github.com/dashevo/platform/tree/master/packages/wallet-lib), as we only cover the most basic pieces in this documentation.
|
|
@@ -28,7 +28,7 @@ const registerContract = async function () {
|
|
|
28
28
|
|
|
29
29
|
const contract = await platform.contracts.create(contractDocuments, identity);
|
|
30
30
|
await platform.dpp.dataContract.validate(contract)
|
|
31
|
-
await platform.contracts.
|
|
31
|
+
await platform.contracts.publish(contract, identity);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
registerContract();
|
package/examples/schema.json
CHANGED