Skip to content

Commit

Permalink
Merge pull request #65 from cruxprotocol/feature/keypair-injection-co…
Browse files Browse the repository at this point in the history
…nfigservice-refactor

add pending registrations call and refactoring of configService
  • Loading branch information
nandubatchu authored Oct 28, 2019
2 parents e9424b4 + 8eec1d6 commit 3adf8f6
Show file tree
Hide file tree
Showing 16 changed files with 619 additions and 344 deletions.
38 changes: 32 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ To initialize the sdk, you need to minimally pass a javascript object with follo
2. BNS(BlockStack Name Service) Node
3. Currency symbol map of your wallet
- To help you get started, you can use `cruxdev` as the value which is already configured for our dev test users. It has 5 pre-registered crypto symbols for a fast start. You can contact us at [telegram](https://t.me/cruxpay_integration) channel for registration of your own walletClientName.
3. **privateKey (optional)**
- Required to re-initialise the CruxClient with same user across different devices.
- For clients using HD derivation paths, recommended to use the path (`m/889'/0/0'`) for CruxPay keypair node derivation with respect to account indices.

`**Note:** Cruxprotocol JS SDK is case insensetive for cryptocurrency symbols and will always output lowercase symbols.`

Expand All @@ -37,7 +40,8 @@ function getPassHashedEncryptionKey() {

let cruxClientOptions = {
getEncryptionKey: getPassHashedEncryptionKey,
walletClientName: 'cruxdev'
walletClientName: 'cruxdev',
privateKey: "6bd397dc89272e71165a0e7d197b280c7a88ed5b1e44e1928c25455506f1968f" // (optional parameter)
}

let cruxClient = new CruxClient(cruxClientOptions);
Expand Down Expand Up @@ -69,17 +73,39 @@ Refer [error-handling.md](https://github.com/cruxprotocol/js-sdk/blob/master/err
- subdomain part of [CruxID](#cruxid)
- Returns: Promise resolving to a _boolean_ indicating whether a particular Crux ID is available for registration.

2. ##### getAssetMapping()
2. ##### getAssetMap()
- Description: Get Wallet's asset map with currency symbols as the keys and asset object as the value.
- Params: None
- Returns: [IResolvedClientAssetMapping](#iresolvedclientassetmapping) which has symbols and asset objects.

3. ##### registerCruxID(cruxID<onlySubdomain>)
- Description: Reserves/registers the cruxID for the user. The user can link any blockchain address to his CruxID with the help of newAddressMap sent. The addresses are now publicly linked and can be resolved.
- Note: To get which currencies can be part of newAddressMap please call `getAssetMapping()`.
- Description: Reserves/registers the cruxID for the user. The user can link any blockchain address to his CruxID immediately after registration using [putAddressMap](#putaddressmap).
- Params:
- subdomain part of [CruxID](#cruxid)
- Returns: Promise resolving on successful call to the registrar.
```javascript
const sampleAddressMap: IAddressMapping = {
'BTC': {
addressHash: '1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX'
},
'ETH': {
addressHash: '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8'
},
}

// Advised to pipe the method putAddressMap to registerCruxID call

await cruxClient.registerCruxID("bob")
.then(() => {
return cruxClient.putAddressMap(sampleAddressMap)
.catch((addressUpdationError) => {
// Handling addressUpdation error
})
})
.catch((registrationError) => {
// Handling registration error
})
```

4. ##### resolveCurrencyAddressForCruxID(cruxID, walletCurrencySymbol)
- Description: Helps to lookup a mapped address for a currency of any CruxID if its marked publically accessible.
Expand All @@ -95,9 +121,9 @@ Refer [error-handling.md](https://github.com/cruxprotocol/js-sdk/blob/master/err

6. ##### putAddressMap(newAddressMap)
- Description: Helps to update 2 things:-
- change list of publicly accessible currency addresses.
- publish/change list of publicly accessible currency addresses.
- change the value of addressHash and/or secIdentifier to another one.
- Note: To get which currencies can be part of newAddressMap please call `getAssetMapping()`.
- Note: The addresses are now publicly linked and can be resolved. To get which currencies can be part of newAddressMap please call `getAssetMapping()`.
- Params:
- newAddressMap of type [IAddressMapping](#iaddressmapping) has modified map has symbols and addresses a user wants to publically expose with CruxID.
- Returns: Promise resolving to {success: [IPutAddressMapSuccess](#iputaddressmapSuccess), failures: [IPutAddressMapFailures](#iputaddressmapfailures)}
Expand Down
2 changes: 2 additions & 0 deletions error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Some common ERROR_CODES thrown by the SDK:
BlockstackIdInvalidSubdomainForTranslation = 4009,
BlockstackIdInvalidDomainForTranslation = 4010,
CurrencyDoesNotExistInClientMapping = 4011,
ExistingCruxIDFound = 4012,
CruxIDUnavailable = 4013,
}
```

Expand Down
Loading

0 comments on commit 3adf8f6

Please sign in to comment.