-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature: list wallet options for a provider & EIP6963 * Remove hard-coded list of wallets * Avoid crash if no wallets installed for a specific crypto * remove useless lowercase calls
- Loading branch information
1 parent
058f1e4
commit 76269c8
Showing
24 changed files
with
522 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,5 @@ | |
"./packages/*/*" | ||
], | ||
"dependencies": { | ||
"assert-never": "^1.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ | |
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"assert-never": "^1.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
}, | ||
"author": "Paima Studios", | ||
"dependencies": { | ||
"assert-never": "^1.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
import type { Result, Wallet } from '../types'; | ||
import type { LoginInfoMap, Result, Wallet } from '../types'; | ||
import { PaimaMiddlewareErrorCode, buildEndpointErrorFxn } from '../errors'; | ||
import { AlgorandConnector } from '@paima/providers'; | ||
import { getGameName } from '../state'; | ||
import type { WalletMode } from './wallet-modes'; | ||
import { connectWallet } from './wallet-modes'; | ||
|
||
export async function algorandLoginWrapper(): Promise<Result<Wallet>> { | ||
export async function algorandLoginWrapper( | ||
loginInfo: LoginInfoMap[WalletMode.ALGORAND] | ||
): Promise<Result<Wallet>> { | ||
const errorFxn = buildEndpointErrorFxn('algorandLoginWrapper'); | ||
|
||
try { | ||
const provider = await AlgorandConnector.instance().connectSimple({ | ||
gameName: getGameName(), | ||
gameChainId: undefined, | ||
}); | ||
return { | ||
success: true, | ||
result: { | ||
walletAddress: provider.getAddress(), | ||
}, | ||
}; | ||
} catch (err) { | ||
return errorFxn(PaimaMiddlewareErrorCode.ALGORAND_LOGIN, err); | ||
const gameInfo = { | ||
gameName: getGameName(), | ||
gameChainId: undefined, // Not needed because of batcher | ||
}; | ||
const loginResult = await connectWallet( | ||
'algorandLoginWrapper', | ||
errorFxn, | ||
PaimaMiddlewareErrorCode.ALGORAND_LOGIN, | ||
loginInfo, | ||
AlgorandConnector.instance(), | ||
gameInfo | ||
); | ||
if (loginResult.success === false) { | ||
return loginResult; | ||
} | ||
return { | ||
success: true, | ||
result: { | ||
walletAddress: loginResult.result.getAddress(), | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.