Skip to content

Commit

Permalink
Small fixes to demo SCs
Browse files Browse the repository at this point in the history
  • Loading branch information
BugFreeSoftware committed Mar 1, 2022
1 parent 7eccd74 commit d5d722a
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion contracts/wasm/dividend/src/dividend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn func_divide(ctx: &ScFuncContext, f: &DivideContext) {
// member address. The transfer_to_address() method receives the address
// value and the proxy to the new transfers map on the host, and will
// call the corresponding host sandbox function with these values.
ctx.transfer_to_address(&address, transfers);
ctx.send(&address, &transfers);
}
}
}
Expand Down
Binary file modified contracts/wasm/dividend/test/dividend_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions contracts/wasm/donatewithfeedback/src/donatewithfeedback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn func_donate(ctx: &ScFuncContext, f: &DonateContext) {
if donation.amount == 0 || donation.feedback.len() == 0 {
donation.error = "error: empty feedback or donated amount = 0".to_string();
if donation.amount > 0 {
ctx.transfer_to_address(&donation.donator.address(), ScTransfers::iotas(donation.amount));
ctx.send(&donation.donator.address(), &ScTransfers::iotas(donation.amount));
donation.amount = 0;
}
}
Expand All @@ -45,7 +45,7 @@ pub fn func_withdraw(ctx: &ScFuncContext, f: &WithdrawContext) {
}

let sc_creator = ctx.contract_creator().address();
ctx.transfer_to_address(&sc_creator, ScTransfers::iotas(amount));
ctx.send(&sc_creator, &ScTransfers::iotas(amount));
}

pub fn view_donation(_ctx: &ScViewContext, f: &DonationContext) {
Expand Down
Binary file modified contracts/wasm/donatewithfeedback/test/donatewithfeedback_bg.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function funcDonate(ctx: wasmlib.ScFuncContext, f: sc.DonateContext): voi
if (donation.amount == 0 || donation.feedback.length == 0) {
donation.error = "error: empty feedback or donated amount = 0".toString();
if (donation.amount > 0) {
ctx.transferToAddress(donation.donator.address(), wasmlib.ScTransfers.iotas(donation.amount));
ctx.send(donation.donator.address(), wasmlib.ScTransfers.iotas(donation.amount));
donation.amount = 0;
}
}
Expand All @@ -43,7 +43,7 @@ export function funcWithdraw(ctx: wasmlib.ScFuncContext, f: sc.WithdrawContext):
}

let scCreator = ctx.contractCreator().address();
ctx.transferToAddress(scCreator, wasmlib.ScTransfers.iotas(amount));
ctx.send(scCreator, wasmlib.ScTransfers.iotas(amount));
}

export function viewDonation(ctx: wasmlib.ScViewContext, f: sc.DonationContext): void {
Expand Down
4 changes: 2 additions & 2 deletions contracts/wasm/fairauction/src/fairauction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ pub fn view_get_info(ctx: &ScViewContext, f: &GetInfoContext) {
fn transfer_tokens(ctx: &ScFuncContext, agent: &ScAgentID, color: &ScColor, amount: u64) {
if agent.is_address() {
// send back to original Tangle address
ctx.transfer_to_address(&agent.address(), ScTransfers::transfer(color, amount));
ctx.send(&agent.address(), &ScTransfers::transfer(color, amount));
return;
}

// TODO not an address, deposit into account on chain
ctx.transfer_to_address(&agent.address(), ScTransfers::transfer(color, amount));
ctx.send(&agent.address(), &ScTransfers::transfer(color, amount));
}
Binary file modified contracts/wasm/fairauction/test/fairauction_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions contracts/wasm/fairauction/ts/fairauction/fairauction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ export function viewGetInfo(ctx: wasmlib.ScViewContext, f: sc.GetInfoContext): v
function transferTokens(ctx: wasmlib.ScFuncContext, agent: wasmlib.ScAgentID, color: wasmlib.ScColor, amount: i64): void {
if (agent.isAddress()) {
// send back to original Tangle address
ctx.transferToAddress(agent.address(), wasmlib.ScTransfers.transfer(color, amount));
ctx.send(agent.address(), wasmlib.ScTransfers.transfer(color, amount));
return;
}

// TODO not an address, deposit into account on chain
ctx.transferToAddress(agent.address(), wasmlib.ScTransfers.transfer(color, amount));
ctx.send(agent.address(), wasmlib.ScTransfers.transfer(color, amount));
}
4 changes: 2 additions & 2 deletions contracts/wasm/fairroulette/go/fairroulette/fairroulette.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func funcPayWinners(ctx wasmlib.ScFuncContext, f *PayWinnersContext) {
// of the winner. The transfer_to_address() method receives the address value and
// the proxy to the new transfers map on the host, and will call the corresponding
// host sandbox function with these values.
ctx.TransferToAddress(bet.Better.Address(), transfers)
ctx.Send(bet.Better.Address(), transfers)
}

// Announce who got sent what as event.
Expand All @@ -227,7 +227,7 @@ func funcPayWinners(ctx wasmlib.ScFuncContext, f *PayWinnersContext) {
transfers := wasmlib.NewScTransferIotas(remainder)

// Send the remainder to the contract creator.
ctx.TransferToAddress(ctx.ContractCreator().Address(), transfers)
ctx.Send(ctx.ContractCreator().Address(), transfers)
}

// Set round status to 0, send out event to notify that the round has ended
Expand Down
4 changes: 2 additions & 2 deletions contracts/wasm/fairroulette/src/fairroulette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) {
// of the winner. The transfer_to_address() method receives the address value and
// the proxy to the new transfers map on the host, and will call the corresponding
// host sandbox function with these values.
ctx.transfer_to_address(&bet.better.address(), transfers);
ctx.send(&bet.better.address(), &transfers);
}

// Announce who got sent what as event.
Expand All @@ -227,7 +227,7 @@ pub fn func_pay_winners(ctx: &ScFuncContext, f: &PayWinnersContext) {
let transfers: ScTransfers = ScTransfers::iotas(remainder);

// Send the remainder to the contract creator.
ctx.transfer_to_address(&ctx.contract_creator().address(), transfers);
ctx.send(&ctx.contract_creator().address(), &transfers);
}

// Set round status to 0, send out event to notify that the round has ended
Expand Down
Binary file modified contracts/wasm/fairroulette/test/fairroulette_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions contracts/wasm/fairroulette/ts/fairroulette/fairroulette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte
// of the winner. The transferToAddress() method receives the address value and
// the proxy to the new transfers map on the host, and will call the corresponding
// host sandbox function with these values.
ctx.transferToAddress(bet.better.address(), transfers);
ctx.send(bet.better.address(), transfers);
}

// Announce who got sent what as event.
Expand All @@ -224,7 +224,7 @@ export function funcPayWinners(ctx: wasmlib.ScFuncContext, f: sc.PayWinnersConte
let transfers: wasmlib.ScTransfers = wasmlib.ScTransfers.iotas(remainder);

// Send the remainder to the contract creator.
ctx.transferToAddress(ctx.contractCreator().address(), transfers);
ctx.send(ctx.contractCreator().address(), transfers);
}

// Set round status to 0, send out event to notify that the round has ended
Expand Down

0 comments on commit d5d722a

Please sign in to comment.