Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Withdraw function is now payable #37

Merged
merged 2 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 36 additions & 23 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
steps:
- label: "build all solidity contracts"
command: |
docker-compose up compile-solidity
git status
changed_files=$$(git status --porcelain --untracked-files=no | wc -l)
if [ $$changed_files -gt 0 ]; then
echo 'contract changed, please rebuild contract'
exit 1
fi
- label: "build all solidity contracts"
command: |
docker-compose up compile-solidity
git status
changed_files=$$(git status --porcelain --untracked-files=no | wc -l)
if [ $$changed_files -gt 0 ]; then
echo 'contract changed, please rebuild contract'
exit 1
fi

- label: "Run Ethereum side tests"
command: |
source ~/.nvm/nvm.sh
source ~/.yarn/yarn.sh
cd erc20-connector
yarn
yarn run test
- label: "build all rust contracts"
command: |
cd bridge-token
./build.sh
cd ../bridge-token-factory
./build.sh
git status
changed_files=$$(git status --porcelain --untracked-files=no | wc -l)
if [ $$changed_files -gt 0 ]; then
echo 'contract changed, please rebuild contract'
exit 1
fi

- label: "Run NEAR side tests"
command: |
source ~/.cargo/env
cd bridge-token-factory
mkdir -p target/debug
./build.sh
cargo test --all
- label: "erc20 connector"
command: |
source ~/.nvm/nvm.sh
source ~/.yarn/yarn.sh
cd erc20-connector
yarn
yarn run test

- label: "bridge token factory"
command: |
source ~/.cargo/env
cd bridge-token-factory
mkdir -p target/debug
./build.sh
cargo test --all
18 changes: 11 additions & 7 deletions bridge-token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ impl BridgeToken {
self.token.mint(account_id, amount.into());
}

#[payable]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return back the deposit? We don't need it to keep it

pub fn withdraw(&mut self, amount: U128, recipient: String) -> Promise {
self.token
.burn(env::predecessor_account_id(), amount.into());
ext_bridge_token_factory::finish_withdraw(
amount.into(),
recipient,
&self.controller,
NO_DEPOSIT,
env::prepaid_gas() / 2,
)

Promise::new(env::signer_account_id())
.transfer(env::attached_deposit())
.then(ext_bridge_token_factory::finish_withdraw(
amount.into(),
recipient,
&self.controller,
NO_DEPOSIT,
env::prepaid_gas() / 2,
))
}
}

Expand Down
Binary file modified res/bridge_token.wasm
Binary file not shown.
Binary file modified res/bridge_token_factory.wasm
Binary file not shown.