diff --git a/config/authz.ts b/config/authz.ts
index 23b8a4f..309512f 100644
--- a/config/authz.ts
+++ b/config/authz.ts
@@ -49,6 +49,7 @@ export function AuthzSendGrantMsg(
denom: string,
spendLimit: number,
expiration: number,
+ allowList?: string[],
): Msg {
const sendAuthValue = SendAuthorization.encode(
SendAuthorization.fromPartial({
@@ -58,15 +59,18 @@ export function AuthzSendGrantMsg(
denom,
}),
],
+ //allowList,
}),
).finish()
+
const grantValue = MsgGrant.fromPartial({
grant: {
authorization: {
typeUrl: '/cosmos.bank.v1beta1.SendAuthorization',
value: sendAuthValue,
},
- //expiration: { seconds: BigInt(expiration).valueOf() },
+ // TODO: fix expiration issue
+ expiration: expiration ? { seconds: BigInt(expiration) } : undefined,
},
grantee,
granter,
diff --git a/pages/authz/grant.tsx b/pages/authz/grant.tsx
index 4126528..a93506f 100644
--- a/pages/authz/grant.tsx
+++ b/pages/authz/grant.tsx
@@ -11,14 +11,14 @@ import { Alert } from 'components/Alert'
import { Conditional } from 'components/Conditional'
import { ContractPageHeader } from 'components/ContractPageHeader'
import { FormControl } from 'components/FormControl'
-import { TextInput } from 'components/forms/FormInput'
-import { useInputState } from 'components/forms/FormInput.hooks'
+import { NumberInput, TextInput } from 'components/forms/FormInput'
+import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
import { InputDateTime } from 'components/InputDateTime'
import { LinkTabs } from 'components/LinkTabs'
import { authzLinkTabs } from 'components/LinkTabs.data'
import { getConfig } from 'config'
import type { Msg } from 'config/authz'
-import { AuthzGenericGrantMsg } from 'config/authz'
+import { AuthzGenericGrantMsg, AuthzSendGrantMsg } from 'config/authz'
import { useGlobalSettings } from 'contexts/globalSettings'
import type { NextPage } from 'next'
import { NextSeo } from 'next-seo'
@@ -66,6 +66,22 @@ const Grant: NextPage = () => {
subtitle: 'The spend limit denom',
})
+ const spendLimitState = useNumberInputState({
+ id: 'spend-limit',
+ name: 'spendLimit',
+ title: 'Spend Limit',
+ placeholder: `1000000`,
+ subtitle: 'The spend limit',
+ })
+
+ const allowListState = useInputState({
+ id: 'allow-list',
+ name: 'allowList',
+ title: 'Allow List',
+ placeholder: `stars1..., stars1...`,
+ subtitle: 'Comma separated list of addresses to allow transactions to',
+ })
+
const messageToSign = () => {
if (authType === 'Generic') {
if (genericAuthType === 'MsgSend') {
@@ -92,6 +108,15 @@ const Grant: NextPage = () => {
(expiration?.getTime() as number) / 1000 || 0,
)
}
+ } else if (authType === 'Send') {
+ return AuthzSendGrantMsg(
+ wallet.address || '',
+ granteeAddressState.value,
+ spendLimitDenomState.value,
+ spendLimitState.value,
+ (expiration?.getTime() as number) / 1000 || 0,
+ allowListState.value ? allowListState.value.split(',').map((address) => address.trim()) : [],
+ )
}
}
const handleSendMessage = async () => {
@@ -130,9 +155,7 @@ const Grant: NextPage = () => {
value={authType}
>
-
+
@@ -170,36 +193,42 @@ const Grant: NextPage = () => {
-
+
+
+ {/* */}
+
+
+
+
+ date
+ ? setExpiration(
+ timezone === 'Local'
+ ? date
+ : new Date(date?.getTime() - new Date().getTimezoneOffset() * 60 * 1000),
+ )
+ : setExpiration(undefined)
+ }
+ value={
+ timezone === 'Local'
+ ? expiration
+ : expiration
+ ? new Date(expiration.getTime() + new Date().getTimezoneOffset() * 60 * 1000)
+ : undefined
+ }
+ />
+
-
-
- date
- ? setExpiration(
- timezone === 'Local' ? date : new Date(date?.getTime() - new Date().getTimezoneOffset() * 60 * 1000),
- )
- : setExpiration(undefined)
- }
- value={
- timezone === 'Local'
- ? expiration
- : expiration
- ? new Date(expiration.getTime() + new Date().getTimezoneOffset() * 60 * 1000)
- : undefined
- }
- />
-