Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development into main #98

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/generate-permits-from-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function generatePermitsFromContext() {

async function returnDataToKernel(repoToken: string, stateId: string, output: object) {
const octokit = new Octokit({ auth: repoToken });
await octokit.repos.createDispatchEvent({
await octokit.rest.repos.createDispatchEvent({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
event_type: "return_data_to_ubiquibot_kernel",
Expand All @@ -93,7 +93,7 @@ async function handleSlashCommands(context: Context, octokit: Octokit) {
const address = matches[0];
// try registering wallet, if it fails, notify the user
if (!(await registerWallet(context, address))) {
await octokit.issues.createComment({
await octokit.rest.issues.createComment({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
issue_number: payload.issue.number,
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/generate-erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function generateErc20PermitSignature(
const config = contextOrPayload.config;
logger = contextOrPayload.logger;
const { evmNetworkId: configEvmNetworkId, evmPrivateEncrypted: configEvmPrivateEncrypted } = config;
const { data: userData } = await contextOrPayload.octokit.users.getByUsername({ username: _username });
const { data: userData } = await contextOrPayload.octokit.rest.users.getByUsername({ username: _username });
if (!userData) {
throw new Error(`GitHub user was not found for id ${_username}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/generate-erc721-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function generateErc721PermitSignature(
}
_organizationName = contextOrPermitPayload.payload.repository.owner.login;
_repositoryName = contextOrPermitPayload.payload.repository.name;
const { data: userData } = await contextOrPermitPayload.octokit.users.getByUsername({ username: _username });
const { data: userData } = await contextOrPermitPayload.octokit.rest.users.getByUsername({ username: _username });
if (!userData) {
throw new Error(`GitHub user was not found for id ${_username}`);
}
Expand Down
25 changes: 13 additions & 12 deletions tests/generate-erc20-permit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ describe("generateErc20PermitSignature", () => {
request() {
return { data: { id: 1, login: "123" } };
},
users: {
getByUsername: jest.fn().mockReturnValue({ data: { id: 123 } }),
rest: {
users: {
getByUsername: jest.fn().mockReturnValue({ data: { id: 123 } }),
},
},
},
} as unknown as Context;
Expand All @@ -69,20 +71,19 @@ describe("generateErc20PermitSignature", () => {
const result = await generateErc20PermitSignature(context, SPENDER, amount, ERC20_REWARD_TOKEN_ADDRESS);

const expectedResult = {
tokenType: 'ERC20',
tokenAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
beneficiary: '0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd',
nonce: '28290789875493039658039458533958603742651083423638415458747066904844975862062',
deadline: '115792089237316195423570985008687907853269984665640564039457584007913129639935',
amount: '100000000000000000000',
owner: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
signature: '0xad87653fb0ecf740c73b78a8f414cdd5b1ffb18670cde5a1d21c65e43d6bb2a36c5470c5529334dc11566f0c380889b734a8539d69ec74cc2abf37af0ea7a7781b',
networkId: 100
tokenType: "ERC20",
tokenAddress: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d",
beneficiary: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd",
nonce: "28290789875493039658039458533958603742651083423638415458747066904844975862062",
deadline: "115792089237316195423570985008687907853269984665640564039457584007913129639935",
amount: "100000000000000000000",
owner: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
signature: "0xad87653fb0ecf740c73b78a8f414cdd5b1ffb18670cde5a1d21c65e43d6bb2a36c5470c5529334dc11566f0c380889b734a8539d69ec74cc2abf37af0ea7a7781b",
networkId: 100,
};

expect(result).toEqual(expectedResult);
expect(context.logger.info).toHaveBeenCalledWith("Generated ERC20 permit2 signature", expect.any(Object));

});

it("should throw error when evmPrivateEncrypted is not defined", async () => {
Expand Down
6 changes: 4 additions & 2 deletions tests/generate-erc721-permit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ describe("generateErc721PermitSignature", () => {
request() {
return { data: { id: 1, login: "123" } };
},
users: {
getByUsername: jest.fn().mockReturnValue({ data: { id: userId } }),
rest: {
users: {
getByUsername: jest.fn().mockReturnValue({ data: { id: userId } }),
},
},
},
} as unknown as Context;
Expand Down
Loading