-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
150 changed files
with
8,629 additions
and
5,625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const BitGoJS = require('bitgo'); | ||
const bitgo = new BitGoJS.BitGo({ env: 'test' }); | ||
const Promise = require('bluebird'); | ||
const coin = 'tada'; | ||
const basecoin = bitgo.coin(coin); | ||
|
||
// TODO: set your access token here | ||
const accessToken = ''; | ||
const walletId = '649b57342f95fd00075b0ab393822a33'; | ||
|
||
// TODO: set your passphrase here | ||
const walletPassphrase = null; | ||
|
||
// TODO: set pledging inputs | ||
const pledgingRawTxHex = ''; | ||
const pledgingNodePubKey = ''; | ||
const pledgingNodeKeySignature = ''; | ||
|
||
Promise.coroutine(function *() { | ||
// generating address w/ same staking key and same payment key | ||
bitgo.authenticateWithAccessToken({ accessToken: accessToken }); | ||
yield bitgo.unlock({ otp: '000000', duration: 3600 }); | ||
const walletInstance = yield basecoin.wallets().get({ id: walletId }); | ||
|
||
const whitelistedParams = { | ||
intent: { | ||
intentType: 'pledge', | ||
rawTx: pledgingRawTxHex, | ||
nodePublicKey: pledgingNodePubKey, | ||
nodeKeySignature: pledgingNodeKeySignature, | ||
}, | ||
apiVersion: 'lite', | ||
preview: undefined, | ||
}; | ||
|
||
const unsignedTx = (yield bitgo | ||
.post(bitgo.url('/wallet/' + walletId + '/txrequests', 2)) | ||
.send(whitelistedParams) | ||
.result()); | ||
|
||
// sign tx | ||
const keychains = yield basecoin.keychains().getKeysForSigning({ wallet: walletInstance }); | ||
const signedStakingTransaction = yield walletInstance.signTransaction({ | ||
txPrebuild: unsignedTx, | ||
keychain: keychains[0], | ||
walletPassphrase: walletPassphrase, | ||
pubs: keychains.map((k) => k.pub), | ||
reqId: unsignedTx.txRequestId, | ||
}); | ||
|
||
// submit tx | ||
const submittedTx = yield bitgo | ||
.post(basecoin.url('/wallet/' + walletId + '/tx/send')) | ||
.send({ txRequestId: signedStakingTransaction.txRequestId }) | ||
.result(); | ||
|
||
console.log('New Transaction:', JSON.stringify(submittedTx, null, 4)); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { TransactionType } from '@bitgo/sdk-core'; | ||
import { BaseCoin as CoinConfig } from '@bitgo/statics'; | ||
|
||
import * as constants from './constants'; | ||
import { ExecuteContractMessage } from './iface'; | ||
import { CosmosTransactionBuilder } from './transactionBuilder'; | ||
import { CosmosUtils } from './utils'; | ||
|
||
export class ContractCallBuilder extends CosmosTransactionBuilder { | ||
protected _utils: CosmosUtils; | ||
|
||
constructor(_coinConfig: Readonly<CoinConfig>, utils: CosmosUtils) { | ||
super(_coinConfig, utils); | ||
this._utils = utils; | ||
} | ||
|
||
protected get transactionType(): TransactionType { | ||
return TransactionType.ContractCall; | ||
} | ||
|
||
/** @inheritdoc */ | ||
messages(messages: ExecuteContractMessage[]): this { | ||
this._messages = messages.map((executeContractMessage) => { | ||
this._utils.validateExecuteContractMessage(executeContractMessage); | ||
return { | ||
typeUrl: constants.executeContractMsgTypeUrl, | ||
value: executeContractMessage, | ||
}; | ||
}); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.json | ||
*.yml | ||
CHANGELOG.md | ||
CHANGELOG.md | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
printWidth: 120 | ||
singleQuote: true | ||
trailingComma: 'es5' |
Oops, something went wrong.