From cc599b12e42035f715220e9aec0865aba3a25848 Mon Sep 17 00:00:00 2001 From: Gege Li Date: Thu, 1 Aug 2024 17:25:35 +0800 Subject: [PATCH 1/4] Use new contract for stake and unstake --- public/images/chains/koi.png | Bin 0 -> 10420 bytes src/config/abi/KTONStakingRewards.ts | 18 ++++++++++++ src/config/chains/darwinia.ts | 2 ++ src/config/chains/index.ts | 1 + src/config/chains/koi.ts | 40 +++++++++++++++++++++++++++ src/hooks/useStake.ts | 2 +- src/hooks/useUnStake.ts | 2 +- src/types/chains.ts | 3 +- src/utils/chain.ts | 5 ++-- 9 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 public/images/chains/koi.png create mode 100644 src/config/chains/koi.ts diff --git a/public/images/chains/koi.png b/public/images/chains/koi.png new file mode 100644 index 0000000000000000000000000000000000000000..78afa23ff8370e39a59861aefbb2495437db2cc0 GIT binary patch literal 10420 zcmeHNeNdD49sdSWpjKY2y8@O-3M=-H5u`{l7y&Jc%n3WYaY8}xrQo4LNO*rq9&2}C zZOL7`iM$BAxf{D76q?h7A()MNy$%EC7$Slg2q8!SfdEM~gnfUcyWaIU29|cZCU?1C zo+spazQ6Cw=kxh~AI|+UBFui>rgZ>dAHFa2AixVWe1n}0p3!;z_A6Xoe}5N;sHHr*MVIC4WgHfM_vGUBRo8G*RQf^WA}YU73vsj;L8&q zrn{ba!>^ZlTcL9NecJi-i1q$q{p0L||Mbkc{Elb!zDK`{5N&LCoYXrjK6szkZKQcI z?hj^!eBgO`V{cPWX}}JS(m2K1@8+?m53M$`!>?hY+y#v>9|na zH#m{AgP|d0DYATNae^fiEagDJz=8=DCs^3QLXj4o@QjEh%KB@Bm``FbOd2Vy%+YPZSTcBE*=mMieW2c{a z*hvFwlScMDdBz)s`rH?Z;?ij56M2W}<%`R)OixB&I; z=dmnxk2p!}Q@7v)@Dt1;S#4u+vSv0H`-7(U7>n(LMGT0bvj6 z>vzs9HFV0~=p@Z>c6R35UD)q@2>-CYd}4kiXExVCd4Qphj*E-4hY)#lp3Vj%w))(a z-UN`Sc{}(sUG-Zk7m^d_aYh&N@uw8tX=O5rXbZ?r!WVy}#W>y8lOnN}O*H8)tI1f6 zdNng6!=GEviofB)DDWRUr@m1ZEqoJ<+iJR!4>#xf!&uO=IEhrdQcHd;YVKS6TtwrX zDxt|h7-Y0qBvOC%=@x6~`x#P+LdemNPgX{`cf=ZVr8~Q6Tyf8OkUgn)Kz{y#WpUq8 zs##(dQiRDS-|}G6W5Z--x`fnY%Yw^y?y?Cc>=>GvNpJ7yK>b^;d{z~Rw~c}oo03%A zQg(@NYAX#B`f`s&wUyQgUHUr>S$@?E8~|Bi+RG~+N)s(6E6z4dt12oh9i9w~jh%An z3V4w37cZQjg|U~2Z|}PHj%T843g;*FQ%a;0ei4@E>sD5IHOnu-cQzjbM1 z`TAabU(z36zZ@B4IDSVn+xI7Vq8|k8ArgYhO6T#W6I0q$DwP|9VJ|z-uvVzyZF4uT zq@;wOp1!Sc$e>k=V`|Y<(6@$$6iFS<;K%=l2k3BaO`T6|TADmXKi8XT3$Xnc9!!vo zp7&|FsMTtbOcfKW(LgJ4KB**-BsL%JI4vc5RThaA0?_wKSF(RcRj@lqPkzhW8ky{H zU|`@T{GFnDHAVXrkC_O>!B_=tQ?{QP9HnmW4sDQ(t z($Mq;5&u8)A#8&1QRXpm&#m*$KEu~eNqT8>qQ$w_Yu&U-qyiA!S{mWkYB)v&iUJ5Q z;=JbVwETQdWF^NHq+Z0ywgc1C({hl#_W4?2%hK71(10)VILN8tz96_*2@TH$cQ}v!k^Kof{$41_-0(dSp>?|x-v2i=-Xrn= literal 0 HcmV?d00001 diff --git a/src/config/abi/KTONStakingRewards.ts b/src/config/abi/KTONStakingRewards.ts index 79de9b5..a90741d 100644 --- a/src/config/abi/KTONStakingRewards.ts +++ b/src/config/abi/KTONStakingRewards.ts @@ -217,5 +217,23 @@ export const abi = [ payable: false, constant: false, stateMutability: 'nonpayable' + }, + { + name: 'lockAndStake', + type: 'function', + inputs: [{ name: 'amount', type: 'uint256', internalType: 'uint256' }], + outputs: [], + payable: false, + constant: false, + stateMutability: 'nonpayable' + }, + { + name: 'unlockAndWithdraw', + type: 'function', + inputs: [{ name: 'amount', type: 'uint256', internalType: 'uint256' }], + outputs: [], + payable: false, + constant: false, + stateMutability: 'nonpayable' } ] as const; diff --git a/src/config/chains/darwinia.ts b/src/config/chains/darwinia.ts index b404dfb..e363f97 100644 --- a/src/config/chains/darwinia.ts +++ b/src/config/chains/darwinia.ts @@ -46,9 +46,11 @@ export const darwinia: ChainConfig = { }, ktonToken: { address: '0x0000000000000000000000000000000000000402', + //address: '0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F', symbol: 'KTON', decimals: 18, logoPath: '/images/token/kton.svg' }, stakingContractAddress: '0x000000000419683a1a03abc21fc9da25fd2b4dd7' + //stakingContractAddress: '0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F' } as const satisfies ChainConfig; diff --git a/src/config/chains/index.ts b/src/config/chains/index.ts index 39954bd..3b9d068 100644 --- a/src/config/chains/index.ts +++ b/src/config/chains/index.ts @@ -1,2 +1,3 @@ export * from './crab'; export * from './darwinia'; +export * from './koi'; diff --git a/src/config/chains/koi.ts b/src/config/chains/koi.ts new file mode 100644 index 0000000..9d13965 --- /dev/null +++ b/src/config/chains/koi.ts @@ -0,0 +1,40 @@ +import { ChainConfig, ChainId } from "@/types/chains"; + +export const koi: ChainConfig = { + id: ChainId.KOI, + name: 'Koi', + nativeCurrency: { name: 'KRING', symbol: 'KRING', decimals: 18 }, + rpcUrls: { + default: { + http: ['https://koi-rpc.darwinia.network'], + webSocket: ['wss://koi-rpc.darwinia.network'] + }, + public: { + http: ['https://koi-rpc.darwinia.network'], + webSocket: ['wss://koi-rpc.darwinia.network'] + } + }, + blockExplorers: { + default: { + name: 'Koi scan', + url: 'https://koi-scan.darwinia.network/' + } + }, + iconUrl: '/images/chains/koi.png', + + /** + * Token info + */ + nativeToken: { + symbol: 'KRING', + decimals: 18, + logoPath: '/images/token/ring.svg' + }, + ktonToken: { + address: '0x0000000000000000000000000000000000000402', + symbol: 'PKTON', + decimals: 18, + logoPath: '/images/token/pkton.svg' + }, + stakingContractAddress: '0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F' +} as const satisfies ChainConfig; \ No newline at end of file diff --git a/src/hooks/useStake.ts b/src/hooks/useStake.ts index 23f65c6..1c9443d 100644 --- a/src/hooks/useStake.ts +++ b/src/hooks/useStake.ts @@ -37,7 +37,7 @@ export function useStake({ ownerAddress, onSuccess, onError }: UseStakeProps) { abi, address: activeChain?.stakingContractAddress, account: ownerAddress!, - functionName: 'stake', + functionName: 'lockAndStake', args: [parseEther(amount)] })?.catch((data) => { updateOperationStatus('stake', 0); diff --git a/src/hooks/useUnStake.ts b/src/hooks/useUnStake.ts index 5ab2822..f6ddab6 100644 --- a/src/hooks/useUnStake.ts +++ b/src/hooks/useUnStake.ts @@ -36,7 +36,7 @@ export function useUnStake({ ownerAddress, onError, onSuccess }: UseUnStakeProps abi, address: activeChain?.stakingContractAddress, account: ownerAddress!, - functionName: 'withdraw', + functionName: 'unlockAndWithdraw', args: [parseEther(amount)] })?.catch((data) => { updateOperationStatus('unstake', 0); diff --git a/src/types/chains.ts b/src/types/chains.ts index 1a75dbd..3c30307 100644 --- a/src/types/chains.ts +++ b/src/types/chains.ts @@ -4,7 +4,8 @@ import type { Chain } from '@rainbow-me/rainbowkit'; */ export enum ChainId { CRAB = 44, - DARWINIA = 46 + DARWINIA = 46, + KOI = 701 } interface NativeToken { diff --git a/src/utils/chain.ts b/src/utils/chain.ts index 0dea8d7..47296ce 100644 --- a/src/utils/chain.ts +++ b/src/utils/chain.ts @@ -1,11 +1,12 @@ -import { darwinia, crab } from '@/config/chains'; +import { darwinia, crab, koi} from '@/config/chains'; import { ChainConfig, ChainId } from '@/types/chains'; // Map object to return a specific chain configuration // Using Record to ensure type safety const chainConfigMap: Record = { [ChainId.DARWINIA]: darwinia, - [ChainId.CRAB]: crab + [ChainId.CRAB]: crab, + [ChainId.KOI]: koi }; // Helper function to filter testnets in production From 115840dbca64c0b7793be35136437609b443c157 Mon Sep 17 00:00:00 2001 From: Gege Li Date: Fri, 9 Aug 2024 18:09:32 +0800 Subject: [PATCH 2/4] Remove comment --- src/config/chains/darwinia.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/config/chains/darwinia.ts b/src/config/chains/darwinia.ts index e363f97..b404dfb 100644 --- a/src/config/chains/darwinia.ts +++ b/src/config/chains/darwinia.ts @@ -46,11 +46,9 @@ export const darwinia: ChainConfig = { }, ktonToken: { address: '0x0000000000000000000000000000000000000402', - //address: '0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F', symbol: 'KTON', decimals: 18, logoPath: '/images/token/kton.svg' }, stakingContractAddress: '0x000000000419683a1a03abc21fc9da25fd2b4dd7' - //stakingContractAddress: '0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F' } as const satisfies ChainConfig; From efc793dcd5828b621fe8994121cdeb4073e96de8 Mon Sep 17 00:00:00 2001 From: fewensa <37804932+fewensa@users.noreply.github.com> Date: Fri, 9 Aug 2024 19:17:20 +0800 Subject: [PATCH 3/4] ci --- .github/workflows/deploy-dev.yml | 2 +- .github/workflows/deploy-prd.yml | 2 +- .github/workflows/deploy-stg.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index c5e0eee..ddcbb20 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -29,7 +29,7 @@ jobs: dist_path: out script_install: pnpm install script_build: pnpm run build - project_name: kton-stake + project_name: kton-stake-v2 enable_cache: true enable_notify_comment: true enable_notify_slack: true diff --git a/.github/workflows/deploy-prd.yml b/.github/workflows/deploy-prd.yml index 67f2810..ed9f89d 100644 --- a/.github/workflows/deploy-prd.yml +++ b/.github/workflows/deploy-prd.yml @@ -31,7 +31,7 @@ jobs: dist_path: out script_install: pnpm install script_build: pnpm run build - project_name: kton-stake + project_name: kton-stake-v2 prod_mode: true enable_cache: true enable_notify_slack: true diff --git a/.github/workflows/deploy-stg.yml b/.github/workflows/deploy-stg.yml index aff7904..2cddfd1 100644 --- a/.github/workflows/deploy-stg.yml +++ b/.github/workflows/deploy-stg.yml @@ -30,8 +30,8 @@ jobs: dist_path: out script_install: pnpm install script_build: pnpm run build - project_name: kton-stake - alias_domain: "kton-stake-stg" + project_name: kton-stake-v2 + alias_domain: "kton-stake-v2-stg" enable_cache: true enable_notify_slack: true slack_channel: public-darwinia-websites-apps From 4f8dca9b02eebe9a9f859db719588570d8de524c Mon Sep 17 00:00:00 2001 From: Gege Li Date: Mon, 12 Aug 2024 13:18:15 +0800 Subject: [PATCH 4/4] Change contract address in koi and crab --- src/config/chains/crab.ts | 2 +- src/config/chains/koi.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/chains/crab.ts b/src/config/chains/crab.ts index 021ec0b..c6015e1 100644 --- a/src/config/chains/crab.ts +++ b/src/config/chains/crab.ts @@ -45,5 +45,5 @@ export const crab: ChainConfig = { decimals: 18, logoPath: '/images/token/ckton.svg' }, - stakingContractAddress: '0x000000000419683a1a03abc21fc9da25fd2b4dd7' + stakingContractAddress: '0xB633Ad1142941CA2Eb9C350579cF88BbE266660D' } as const satisfies ChainConfig; diff --git a/src/config/chains/koi.ts b/src/config/chains/koi.ts index 9d13965..3c0c51f 100644 --- a/src/config/chains/koi.ts +++ b/src/config/chains/koi.ts @@ -36,5 +36,5 @@ export const koi: ChainConfig = { decimals: 18, logoPath: '/images/token/pkton.svg' }, - stakingContractAddress: '0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F' + stakingContractAddress: '0xB633Ad1142941CA2Eb9C350579cF88BbE266660D' } as const satisfies ChainConfig; \ No newline at end of file