Skip to content

Commit

Permalink
Merge pull request #160 from AElfProject/feature/ecoEarn-support
Browse files Browse the repository at this point in the history
Feature/eco earn support
  • Loading branch information
aelf-lxy authored Sep 30, 2024
2 parents d5bafbf + d5a81c4 commit 0eded53
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 137 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,26 @@ const didConfig = {
botId: TELEGRAM_BOT_ID,
},
},
// customNetworkType: NETWORK_TYPE === 'TESTNET' ? 'offline' : 'online',
// loginConfig: {
// loginMethodsOrder: [ "Email", "Google" , "Apple" , "Scan"]
// }
};

const baseConfig = {
showVconsole: false,
// ConfirmLogoutDialog: CustomizedConfirmLogoutDialog,
// SignInComponent: SignInProxy,
// defaultPin: '111111',
// PortkeyProviderProps: {
// theme: 'light' as any,
// },
// omitTelegramScript: false,
// cancelAutoLoginInTelegram: false,
enableAcceleration: true,
networkType: NETWORK_TYPE,
chainId: CHAIN_ID,
showVconsole: false,
chainId: CHAIN_ID,
keyboard: true,
noCommonBaseModal: false,
design: SignInDesignEnum.CryptoDesign, // "SocialDesign" | "CryptoDesign" | "Web2Design"
Expand All @@ -106,6 +120,7 @@ const wallets = [
appName: APP_NAME,
chainId: CHAIN_ID,
autoShowUnlock: true,
noNeedForConfirm: false,
}),
new PortkeyDiscoverWallet({
networkType: NETWORK_TYPE,
Expand Down
8 changes: 4 additions & 4 deletions packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-base",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -33,8 +33,8 @@
"@babel/core": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@portkey/did-ui-react": "^2.11.0-alpha.4",
"@portkey/types": "^2.11.0-alpha.4",
"@portkey/did-ui-react": "^2.11.0-alpha.10",
"@portkey/types": "^2.11.0-alpha.10",
"@types/jest": "^29.5.12",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
Expand All @@ -44,7 +44,7 @@
"typescript": "^5.3.3"
},
"peerDependencies": {
"@portkey/did-ui-react": "^2.11.0-alpha.4"
"@portkey/did-ui-react": "^2.11.0-alpha.10"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-bridge",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -29,21 +29,21 @@
},
"dependencies": {
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/services": "^2.11.0-alpha.4",
"@portkey/services": "^2.11.0-alpha.10",
"@reduxjs/toolkit": "^2.2.3",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@portkey/did-ui-react": "^2.11.0-alpha.4",
"@portkey/did-ui-react": "^2.11.0-alpha.10",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"antd": "4.24.14",
"father": "^4.3.8",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@portkey/did-ui-react": "^2.11.0-alpha.4"
"@portkey/did-ui-react": "^2.11.0-alpha.10"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-react",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"flatted": "^3.3.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@portkey/did-ui-react": "^2.11.0-alpha.4"
"@portkey/did-ui-react": "^2.11.0-alpha.10"
},
"devDependencies": {
"@types/react": "^18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/starter/src/Demo/demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const App: React.FC = () => {
return (
<WebLoginProvider bridgeAPI={bridgeAPI}>
<LoginDemo />
<Tabs defaultActiveKey="AccountDemo" items={items} />
<Tabs defaultActiveKey="ContractDemo" items={items} />
</WebLoginProvider>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/utils",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand Down
6 changes: 3 additions & 3 deletions packages/wallets/night-elf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-night-elf",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -26,13 +26,13 @@
},
"dependencies": {
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/contracts": "^2.11.0-alpha.4",
"@portkey/contracts": "^2.11.0-alpha.10",
"aelf-bridge": "^0.0.11-alpha.4",
"bn.js": "^5.2.1"
},
"devDependencies": {
"@aelf-react/types": "^0.1.10",
"@portkey/types": "^2.11.0-alpha.4",
"@portkey/types": "^2.11.0-alpha.10",
"@types/bn.js": "^5.1.5",
"father": "^4.3.8",
"typescript": "^5.3.3"
Expand Down
12 changes: 6 additions & 6 deletions packages/wallets/portkey-aa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-portkey-aa",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -26,17 +26,17 @@
},
"dependencies": {
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/contracts": "^2.11.0-alpha.4",
"@portkey/utils": "^2.11.0-alpha.4"
"@portkey/contracts": "^2.11.0-alpha.10",
"@portkey/utils": "^2.11.0-alpha.10"
},
"devDependencies": {
"@portkey/did-ui-react": "^2.11.0-alpha.4",
"@portkey/types": "^2.11.0-alpha.4",
"@portkey/did-ui-react": "^2.11.0-alpha.10",
"@portkey/types": "^2.11.0-alpha.10",
"father": "^4.3.8",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@portkey/did-ui-react": "^2.11.0-alpha.4"
"@portkey/did-ui-react": "^2.11.0-alpha.10"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
Expand Down
34 changes: 28 additions & 6 deletions packages/wallets/portkey-aa/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export class PortkeyAAWallet extends BaseWalletAdapter {
private _loginState: LoginStateEnum;
private _wallet: TWalletInfo | null;
private _config: IPortkeyAAWalletAdapterConfig;
private _registerChainId: TChainId | null;
private _sessionId: string;
private _status: TStatus;
private _pin: string;

constructor(config: IPortkeyAAWalletAdapterConfig) {
super();
this._loginState = LoginStateEnum.INITIAL;
this._wallet = null;
this._config = config;
this._registerChainId = null;
this._sessionId = '';
this._pin = '';
this._status = 'initial';
this.autoRequestAccountHandler();
}
Expand Down Expand Up @@ -95,9 +95,9 @@ export class PortkeyAAWallet extends BaseWalletAdapter {
async loginWithAcceleration(createPendingInfo: CreatePendingInfo): Promise<TWalletInfo> {
console.log('createPendingInfo is', createPendingInfo);
const didWallet = createPendingInfo.didWallet as DIDWalletInfo;
this._registerChainId = didWallet.chainId;
this._sessionId = createPendingInfo.sessionId;
this._status = 'inCreatePending';
this._pin = createPendingInfo.pin;
return this.login(didWallet);
}

Expand Down Expand Up @@ -253,6 +253,26 @@ export class PortkeyAAWallet extends BaseWalletAdapter {
nickName = holderInfo.nickName;
}

if (!localWallet.didWallet.sessionId) {
console.log('-----unlock in checkManagerIsExistByGQL');
const result = await did.didWallet.checkManagerIsExistByGQL({
chainId: originChainId,
caHash,
managementAddress: localWallet.didWallet.managementAccount?.address ?? '',
});
if (result) {
await did.save(password, this.appName);
} else {
// logout
}
}

console.log(
'----unlock after checkManagerIsExistByGQL',
caHash,
localWallet.didWallet.sessionId,
);

const didWalletInfo: DIDWalletInfo = {
caInfo,
pin: password,
Expand Down Expand Up @@ -466,12 +486,13 @@ export class PortkeyAAWallet extends BaseWalletAdapter {
if (this._status === 'inCreatePending') {
console.log(
'----------in callSendMethod and _status is inCreatePending, begin to execute getLoginStatus, sessionId=',
this._sessionId,
did.didWallet.sessionId,
);
const { recoveryStatus } = await did.didWallet.getLoginStatus({
sessionId: this._sessionId,
chainId: this._registerChainId!,
sessionId: did.didWallet.sessionId!,
chainId: did.didWallet.originChainId!,
});
await did.save(this._pin, this.appName);
console.log(
'----------in callSendMethod and after execute getLoginStatus, recoveryStatus=',
recoveryStatus,
Expand All @@ -480,6 +501,7 @@ export class PortkeyAAWallet extends BaseWalletAdapter {
throw makeError(ERR_CODE.GET_LOGIN_STATUS_FAIL);
}
}
console.log('did.didWallet.isLoginStatus-contract', did.didWallet.isLoginStatus);
// if (this._status === 'inFinish' && did.didWallet.isLoginStatus !== 'SUCCESS') {
// throw makeError(ERR_CODE.IN_FINISH_BUT_STATUS_IS_NOT_SUCCESS);
// }
Expand Down
8 changes: 4 additions & 4 deletions packages/wallets/portkey-discover/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aelf-web-login/wallet-adapter-portkey-discover",
"version": "0.1.12-alpha.3",
"version": "0.1.13",
"type": "module",
"main": "dist/esm/index.js",
"module": "dist/esm/index.js",
Expand All @@ -26,14 +26,14 @@
},
"dependencies": {
"@aelf-web-login/wallet-adapter-base": "workspace:*",
"@portkey/contracts": "^2.11.0-alpha.4",
"@portkey/contracts": "^2.11.0-alpha.10",
"@portkey/detect-provider": "^2.2.0",
"@portkey/provider-types": "^2.2.0",
"@portkey/utils": "^2.11.0-alpha.4",
"@portkey/utils": "^2.11.0-alpha.10",
"bn.js": "^5.2.1"
},
"devDependencies": {
"@portkey/types": "^2.11.0-alpha.4",
"@portkey/types": "^2.11.0-alpha.10",
"@types/bn.js": "^5.1.5",
"father": "^4.3.8",
"typescript": "^5.3.3"
Expand Down
Loading

0 comments on commit 0eded53

Please sign in to comment.