-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(act): add act * feat(act): rename addGrantees to createGrantees * feat(act): remove mention of ENS name in getGrantees method comment * feat(act): add grantee module for managing grantees * feat(act): revert import chai and jestExpect in bzz.spec.ts * feat(act): improve documentation for the createGrantees method * feat(act)!: update the return type of chunk upload to UploadResult from Reference * feat(act)!: update the return type of soc upload to UploadResult from Reference * feat(act): fix linter errors --------- Co-authored-by: Ferenc Sárai <[email protected]>
- Loading branch information
1 parent
a007152
commit 09f22ee
Showing
18 changed files
with
386 additions
and
22 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
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { BatchId, BeeRequestOptions, GetGranteesResult, GranteesResult } from '../types' | ||
import { extractRedundantUploadHeaders } from '../utils/headers' | ||
import { http } from '../utils/http' | ||
|
||
const granteeEndpoint = 'grantee' | ||
|
||
export async function getGrantees(reference: string, requestOptions: BeeRequestOptions): Promise<GetGranteesResult> { | ||
const response = await http<GetGranteesResult>(requestOptions, { | ||
method: 'get', | ||
url: `${granteeEndpoint}/${reference}`, | ||
responseType: 'json', | ||
}) | ||
|
||
return { | ||
status: response.status, | ||
statusText: response.statusText, | ||
data: response.data.data, | ||
} | ||
} | ||
|
||
export async function createGrantees( | ||
requestOptions: BeeRequestOptions, | ||
postageBatchId: BatchId, | ||
grantees: string[], | ||
): Promise<GranteesResult> { | ||
const response = await http<GranteesResult>(requestOptions, { | ||
method: 'post', | ||
url: granteeEndpoint, | ||
data: { grantees: grantees }, | ||
headers: { | ||
...extractRedundantUploadHeaders(postageBatchId), | ||
}, | ||
responseType: 'json', | ||
}) | ||
|
||
return { | ||
status: response.status, | ||
statusText: response.statusText, | ||
ref: response.data.ref, | ||
historyref: response.data.historyref, | ||
} | ||
} | ||
|
||
export async function patchGrantees( | ||
reference: string, | ||
historyRef: string, | ||
postageBatchId: BatchId, | ||
grantees: string, | ||
requestOptions: BeeRequestOptions, | ||
): Promise<GranteesResult> { | ||
const response = await http<GranteesResult>(requestOptions, { | ||
method: 'patch', | ||
url: `${granteeEndpoint}/${reference}`, | ||
data: grantees, | ||
headers: { | ||
...extractRedundantUploadHeaders(postageBatchId), | ||
'swarm-act-history-address': historyRef, | ||
}, | ||
responseType: 'json', | ||
}) | ||
|
||
return { | ||
status: response.status, | ||
statusText: response.statusText, | ||
ref: response.data.ref, | ||
historyref: response.data.historyref, | ||
} | ||
} |
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.