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

[Feature]: Remove beth burn functionalities due to the wormhole migration #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anchor-protocol/anchor.js",
"version": "4.0.0",
"version": "4.1.0",
"author": "Anchor Protocol",
"license": "MIT",
"repository": "github:Anchor-Protocol/anchor.js",
Expand Down
80 changes: 40 additions & 40 deletions src/__tests__/anchor-beth-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { testFabricator } from '../utils/test-fabricators/test-fabricator';
import {
Expire,
fabricatebEthBurn,
fabricatebEthBurnFrom,
// fabricatebEthBurn,
// fabricatebEthBurnFrom,
fabricatebEthDecreaseAllowance,
fabricatebEthIncreaseAllowance,
fabricatebEthSend,
Expand Down Expand Up @@ -100,45 +100,45 @@ describe('bEth', () => {
);
});

it('burn', async () => {
testFabricator(
expect,
fabricatebEthBurn,
{
address: 'address',
amount: '1000',
},
addressProvider,
[
new MsgExecuteContract('address', addressProvider.bEthToken(), {
burn: {
amount: new Int(new Dec('1000').mul(1000000)).toString(),
},
}),
],
);
});
// it('burn', async () => {
// testFabricator(
// expect,
// fabricatebEthBurn,
// {
// address: 'address',
// amount: '1000',
// },
// addressProvider,
// [
// new MsgExecuteContract('address', addressProvider.bEthToken(), {
// burn: {
// amount: new Int(new Dec('1000').mul(1000000)).toString(),
// },
// }),
// ],
// );
// });

it('burn-from', async () => {
testFabricator(
expect,
fabricatebEthBurnFrom,
{
address: 'address',
owner: 'owner',
amount: '1000',
},
addressProvider,
[
new MsgExecuteContract('address', addressProvider.bEthToken(), {
burn_from: {
owner: 'owner',
amount: new Int(new Dec('1000').mul(1000000)).toString(),
},
}),
],
);
});
// it('burn-from', async () => {
// testFabricator(
// expect,
// fabricatebEthBurnFrom,
// {
// address: 'address',
// owner: 'owner',
// amount: '1000',
// },
// addressProvider,
// [
// new MsgExecuteContract('address', addressProvider.bEthToken(), {
// burn_from: {
// owner: 'owner',
// amount: new Int(new Dec('1000').mul(1000000)).toString(),
// },
// }),
// ],
// );
// });

it('send', async () => {
testFabricator(
Expand Down
88 changes: 47 additions & 41 deletions src/fabricators/beth/beth-burn-from.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
import { AddressProvider } from '../../address-provider/provider';
import { Dec, Int, MsgExecuteContract } from '@terra-money/terra.js';
import { validateInput } from '../../utils/validate-input';
import { validateAddress } from '../../utils/validation/address';
import {
validateIsGreaterThanZero,
validateIsNumber,
} from '../../utils/validation/number';
/*
Due to the bETH wormhole migration on 2021–01-26, message fabricators for bETH burn (fabricatebEthBurn
and fabricatebEthBurnFrom) will no longer result in retrieval of ERC-20 bETH tokens on Ethereum,
(a functionality supported previously by Shuttle) but will just be used as regular CW20 token burn.
*/

/**
* @param address Client’s Terra address (address of the message sender).
* @param amount of burn.
* @param owner Client's Terra address (address of allowance owner).
*/

interface Option {
address: string;
amount: string;
owner: string;
}

export const fabricatebEthBurnFrom =
({ address, amount, owner }: Option) =>
(addressProvider: AddressProvider): MsgExecuteContract[] => {
validateInput([
validateAddress(address),
validateIsNumber(amount),
validateIsGreaterThanZero(amount),
validateAddress(owner),
]);

const bEthTokenAddress = addressProvider.bEthToken();

return [
new MsgExecuteContract(address, bEthTokenAddress, {
burn_from: {
owner: owner,
amount: new Int(new Dec(amount).mul(1000000)).toString(),
},
}),
];
};
// import { AddressProvider } from '../../address-provider/provider';
// import { Dec, Int, MsgExecuteContract } from '@terra-money/terra.js';
// import { validateInput } from '../../utils/validate-input';
// import { validateAddress } from '../../utils/validation/address';
// import {
// validateIsGreaterThanZero,
// validateIsNumber,
// } from '../../utils/validation/number';
//
// /**
// * @param address Client’s Terra address (address of the message sender).
// * @param amount of burn.
// * @param owner Client's Terra address (address of allowance owner).
// */
//
// interface Option {
// address: string;
// amount: string;
// owner: string;
// }
//
// export const fabricatebEthBurnFrom =
// ({ address, amount, owner }: Option) =>
// (addressProvider: AddressProvider): MsgExecuteContract[] => {
// validateInput([
// validateAddress(address),
// validateIsNumber(amount),
// validateIsGreaterThanZero(amount),
// validateAddress(owner),
// ]);
//
// const bEthTokenAddress = addressProvider.bEthToken();
//
// return [
// new MsgExecuteContract(address, bEthTokenAddress, {
// burn_from: {
// owner: owner,
// amount: new Int(new Dec(amount).mul(1000000)).toString(),
// },
// }),
// ];
// };
78 changes: 42 additions & 36 deletions src/fabricators/beth/beth-burn.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import { Dec, Int, MsgExecuteContract } from '@terra-money/terra.js';
import { validateInput } from '../../utils/validate-input';
import { validateAddress } from '../../utils/validation/address';
import {
validateIsGreaterThanZero,
validateIsNumber,
} from '../../utils/validation/number';
import { AddressProvider } from '../../address-provider';
/*
Due to the bETH wormhole migration on 2021–01-26, message fabricators for bETH burn (fabricatebEthBurn
and fabricatebEthBurnFrom) will no longer result in retrieval of ERC-20 bETH tokens on Ethereum,
(a functionality supported previously by Shuttle) but will just be used as regular CW20 token burn.
*/

/**
* @param address Client’s Terra address (address of the message sender).
* @param amount of burn.
*/

interface Option {
address: string;
amount: string;
}

export const fabricatebEthBurn =
({ address, amount }: Option) =>
(addressProvider: AddressProvider): MsgExecuteContract[] => {
validateInput([
validateAddress(address),
validateIsNumber(amount),
validateIsGreaterThanZero(amount),
]);

const bEthTokenAddress = addressProvider.bEthToken();
return [
new MsgExecuteContract(address, bEthTokenAddress, {
burn: {
amount: new Int(new Dec(amount).mul(1000000)).toString(),
},
}),
];
};
// import { Dec, Int, MsgExecuteContract } from '@terra-money/terra.js';
// import { validateInput } from '../../utils/validate-input';
// import { validateAddress } from '../../utils/validation/address';
// import {
// validateIsGreaterThanZero,
// validateIsNumber,
// } from '../../utils/validation/number';
// import { AddressProvider } from '../../address-provider';
//
// /**
// * @param address Client’s Terra address (address of the message sender).
// * @param amount of burn.
// */
//
// interface Option {
// address: string;
// amount: string;
// }
//
// export const fabricatebEthBurn =
// ({ address, amount }: Option) =>
// (addressProvider: AddressProvider): MsgExecuteContract[] => {
// validateInput([
// validateAddress(address),
// validateIsNumber(amount),
// validateIsGreaterThanZero(amount),
// ]);
//
// const bEthTokenAddress = addressProvider.bEthToken();
// return [
// new MsgExecuteContract(address, bEthTokenAddress, {
// burn: {
// amount: new Int(new Dec(amount).mul(1000000)).toString(),
// },
// }),
// ];
// };
4 changes: 2 additions & 2 deletions src/fabricators/beth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export * from './beth-send';
export * from './beth-send-from';
export * from './beth-transfer-from';
export * from './beth-transfer';
export * from './beth-burn';
export * from './beth-burn-from';
// export * from './beth-burn';
// export * from './beth-burn-from';