forked from binary-star-near/usdt-gold
-
Notifications
You must be signed in to change notification settings - Fork 1
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
2 changed files
with
100 additions
and
0 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,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit script as soon as a command fails. | ||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
NAME="build_tether_near" | ||
|
||
if docker ps -a --format '{{.Names}}' | grep -Eq "^${NAME}\$"; then | ||
echo "Container exists" | ||
else | ||
docker create \ | ||
--mount type=bind,source=$DIR/..,target=/host \ | ||
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \ | ||
--name=$NAME \ | ||
-w /host/tether-near \ | ||
-e RUSTFLAGS='-C link-arg=-s' \ | ||
-it \ | ||
nearprotocol/contract-builder \ | ||
/bin/bash | ||
fi | ||
|
||
docker start $NAME | ||
docker exec -it $NAME /bin/bash -c "rustup toolchain install stable; rustup default stable; rustup target add wasm32-unknown-unknown; cargo build --target wasm32-unknown-unknown --profile release; cargo test" | ||
|
||
mkdir -p $DIR/../res | ||
cp $DIR/../target/wasm32-unknown-unknown/release/tether_token.wasm $DIR/../res/tether_token.wasm |
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,72 @@ | ||
'use strict'; | ||
const nearAPI = require('near-api-js'); | ||
const { Contract } = nearAPI; | ||
const BN = require('bn.js'); | ||
const fs = require('fs').promises; | ||
const assert = require('assert').strict; | ||
|
||
//const config = { | ||
// networkId: 'testnet', | ||
// nodeUrl: 'https://rpc.testnet.near.org', | ||
// keyPath: '/home/user/.near-credentials/testnet/user.testnet.json', | ||
// contractPath: './res/tether_token.wasm', | ||
// accountId: 'user.testnet', | ||
// contractId: 'usdt.token', | ||
// msafeId: 'vault.multisafe', | ||
//}; | ||
|
||
const config = { | ||
networkId: 'mainnet', | ||
nodeUrl: 'https://rpc.mainnet.near.org', | ||
keyPath: '/home/user/.near-credentials/mainnet/user.json', | ||
contractPath: './res/tether_token.wasm', | ||
accountId: 'user', | ||
contractId: 'usdt.tether-token.near', | ||
msafeId: 'tether.multisafe.near', | ||
}; | ||
|
||
(async function () { | ||
const keyFile = require(config.keyPath); | ||
const privKey = nearAPI.utils.KeyPair.fromString(keyFile.private_key); | ||
|
||
const keyStore = new nearAPI.keyStores.InMemoryKeyStore(); | ||
keyStore.setKey(config.networkId, config.accountId, privKey); | ||
|
||
const near = await nearAPI.connect({ | ||
deps: { | ||
keyStore, | ||
}, | ||
networkId: config.networkId, | ||
nodeUrl: config.nodeUrl, | ||
}); | ||
|
||
const wasm = await fs.readFile(config.contractPath); | ||
const account = new nearAPI.Account(near.connection, config.accountId); | ||
const contract = new Contract( | ||
account, | ||
config.msafeId, | ||
{ | ||
changeMethods: ['add_request_and_confirm'], | ||
sender: account, | ||
} | ||
); | ||
|
||
// Send Upgrade contract to multisafe. | ||
await contract.add_request_and_confirm({ | ||
request: { | ||
receiver_id: config.contractId, | ||
actions: [ | ||
{ | ||
type: 'FunctionCall', | ||
method_name: 'upgrade', | ||
args: wasm.toString('base64'), | ||
deposit:'0', | ||
gas: '250000000000000', | ||
}, | ||
], | ||
} | ||
}, | ||
300000000000000 | ||
); | ||
|
||
})(); |