Skip to content

Commit

Permalink
Add getTokenAllowance function to oauth-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
SoraSuegami committed Jul 19, 2024
1 parent dc5209b commit c5ea299
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/oauth-sdk/src/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export const iOauthAbi = [
{ name: 'nonce', internalType: 'uint256', type: 'uint256' },
{ name: 'tokenAddr', internalType: 'address', type: 'address' },
],
name: 'getTokenAkkowancesOfWalletAndNonce',
name: 'getTokenAllowancesOfWalletAndNonce',
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
stateMutability: 'view',
},
Expand Down
10 changes: 9 additions & 1 deletion packages/oauth-sdk/src/oauthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,13 @@ export default class OauthClient<chain extends Chain> {
return txHash;
}


public async getTokenAllowance(
tokenAddr: Address
): Promise<bigint> {
if (this.userWallet === null || this.epheAddrNonce === null) {
throw new Error("Not signed in yet")
}
const res = await this.oauth.read.getTokenAllowancesOfWalletAndNonce([this.userWallet.address, this.epheAddrNonce, tokenAddr]);
return BigInt(res);
}
}
4 changes: 2 additions & 2 deletions packages/relayer/src/abis/account_handler.rs

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions packages/relayer/src/abis/ioauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ pub mod i_oauth {
),
(
::std::borrow::ToOwned::to_owned(
"getTokenAkkowancesOfWalletAndNonce",
"getTokenAllowancesOfWalletAndNonce",
),
::std::vec![
::ethers::core::abi::ethabi::Function {
name: ::std::borrow::ToOwned::to_owned(
"getTokenAkkowancesOfWalletAndNonce",
"getTokenAllowancesOfWalletAndNonce",
),
inputs: ::std::vec![
::ethers::core::abi::ethabi::Param {
Expand Down Expand Up @@ -588,15 +588,15 @@ pub mod i_oauth {
.method_hash([181, 112, 58, 85], (wallet, nonce))
.expect("method not found (this should never happen)")
}
///Calls the contract's `getTokenAkkowancesOfWalletAndNonce` (0x96edff31) function
pub fn get_token_akkowances_of_wallet_and_nonce(
///Calls the contract's `getTokenAllowancesOfWalletAndNonce` (0xeb1202ff) function
pub fn get_token_allowances_of_wallet_and_nonce(
&self,
wallet: ::ethers::core::types::Address,
nonce: ::ethers::core::types::U256,
token_addr: ::ethers::core::types::Address,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
self.0
.method_hash([150, 237, 255, 49], (wallet, nonce, token_addr))
.method_hash([235, 18, 2, 255], (wallet, nonce, token_addr))
.expect("method not found (this should never happen)")
}
///Calls the contract's `getUsernameOfWallet` (0x7218fda4) function
Expand Down Expand Up @@ -899,7 +899,7 @@ pub mod i_oauth {
pub wallet: ::ethers::core::types::Address,
pub nonce: ::ethers::core::types::U256,
}
///Container type for all input parameters for the `getTokenAkkowancesOfWalletAndNonce` function with signature `getTokenAkkowancesOfWalletAndNonce(address,uint256,address)` and selector `0x96edff31`
///Container type for all input parameters for the `getTokenAllowancesOfWalletAndNonce` function with signature `getTokenAllowancesOfWalletAndNonce(address,uint256,address)` and selector `0xeb1202ff`
#[derive(
Clone,
::ethers::contract::EthCall,
Expand All @@ -911,10 +911,10 @@ pub mod i_oauth {
Hash
)]
#[ethcall(
name = "getTokenAkkowancesOfWalletAndNonce",
abi = "getTokenAkkowancesOfWalletAndNonce(address,uint256,address)"
name = "getTokenAllowancesOfWalletAndNonce",
abi = "getTokenAllowancesOfWalletAndNonce(address,uint256,address)"
)]
pub struct GetTokenAkkowancesOfWalletAndNonceCall {
pub struct GetTokenAllowancesOfWalletAndNonceCall {
pub wallet: ::ethers::core::types::Address,
pub nonce: ::ethers::core::types::U256,
pub token_addr: ::ethers::core::types::Address,
Expand Down Expand Up @@ -1065,7 +1065,7 @@ pub mod i_oauth {
#[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
pub enum IOauthCalls {
GetInfoOfWalletAndNonce(GetInfoOfWalletAndNonceCall),
GetTokenAkkowancesOfWalletAndNonce(GetTokenAkkowancesOfWalletAndNonceCall),
GetTokenAllowancesOfWalletAndNonce(GetTokenAllowancesOfWalletAndNonceCall),
GetUsernameOfWallet(GetUsernameOfWalletCall),
GetWalletOfUsername(GetWalletOfUsernameCall),
ReduceTokenAllowance(ReduceTokenAllowanceCall),
Expand All @@ -1085,10 +1085,10 @@ pub mod i_oauth {
) {
return Ok(Self::GetInfoOfWalletAndNonce(decoded));
}
if let Ok(decoded) = <GetTokenAkkowancesOfWalletAndNonceCall as ::ethers::core::abi::AbiDecode>::decode(
if let Ok(decoded) = <GetTokenAllowancesOfWalletAndNonceCall as ::ethers::core::abi::AbiDecode>::decode(
data,
) {
return Ok(Self::GetTokenAkkowancesOfWalletAndNonce(decoded));
return Ok(Self::GetTokenAllowancesOfWalletAndNonce(decoded));
}
if let Ok(decoded) = <GetUsernameOfWalletCall as ::ethers::core::abi::AbiDecode>::decode(
data,
Expand Down Expand Up @@ -1139,7 +1139,7 @@ pub mod i_oauth {
Self::GetInfoOfWalletAndNonce(element) => {
::ethers::core::abi::AbiEncode::encode(element)
}
Self::GetTokenAkkowancesOfWalletAndNonce(element) => {
Self::GetTokenAllowancesOfWalletAndNonce(element) => {
::ethers::core::abi::AbiEncode::encode(element)
}
Self::GetUsernameOfWallet(element) => {
Expand Down Expand Up @@ -1171,7 +1171,7 @@ pub mod i_oauth {
Self::GetInfoOfWalletAndNonce(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::GetTokenAkkowancesOfWalletAndNonce(element) => {
Self::GetTokenAllowancesOfWalletAndNonce(element) => {
::core::fmt::Display::fmt(element, f)
}
Self::GetUsernameOfWallet(element) => {
Expand All @@ -1196,9 +1196,9 @@ pub mod i_oauth {
Self::GetInfoOfWalletAndNonce(value)
}
}
impl ::core::convert::From<GetTokenAkkowancesOfWalletAndNonceCall> for IOauthCalls {
fn from(value: GetTokenAkkowancesOfWalletAndNonceCall) -> Self {
Self::GetTokenAkkowancesOfWalletAndNonce(value)
impl ::core::convert::From<GetTokenAllowancesOfWalletAndNonceCall> for IOauthCalls {
fn from(value: GetTokenAllowancesOfWalletAndNonceCall) -> Self {
Self::GetTokenAllowancesOfWalletAndNonce(value)
}
}
impl ::core::convert::From<GetUsernameOfWalletCall> for IOauthCalls {
Expand Down Expand Up @@ -1256,7 +1256,7 @@ pub mod i_oauth {
pub ::ethers::core::types::Address,
pub ::ethers::core::types::U256,
);
///Container type for all return fields from the `getTokenAkkowancesOfWalletAndNonce` function with signature `getTokenAkkowancesOfWalletAndNonce(address,uint256,address)` and selector `0x96edff31`
///Container type for all return fields from the `getTokenAllowancesOfWalletAndNonce` function with signature `getTokenAllowancesOfWalletAndNonce(address,uint256,address)` and selector `0xeb1202ff`
#[derive(
Clone,
::ethers::contract::EthAbiType,
Expand All @@ -1267,7 +1267,7 @@ pub mod i_oauth {
Eq,
Hash
)]
pub struct GetTokenAkkowancesOfWalletAndNonceReturn(pub ::ethers::core::types::U256);
pub struct GetTokenAllowancesOfWalletAndNonceReturn(pub ::ethers::core::types::U256);
///Container type for all return fields from the `getUsernameOfWallet` function with signature `getUsernameOfWallet(address)` and selector `0x7218fda4`
#[derive(
Clone,
Expand Down
4 changes: 2 additions & 2 deletions packages/relayer/src/abis/nft_extension.rs

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions packages/relayer/src/abis/oauth_core.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/relayer/src/abis/unclaims_handler.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/relayer/src/abis/wallet.rs

Large diffs are not rendered by default.

0 comments on commit c5ea299

Please sign in to comment.